<script src='js.js'></script>
<input type="button" οnclick="alert('you clicked the button!')" value="Click Me"/>
<img src="1.png" alt="one" οnmοuseοver="alert('you entered the image!')" />
<img src="2.png" alt="two" οnclick="this.title='My New Title'" />
事件处理器
onClick点击之后产生的效果
onMouseOver检测鼠标指针进入页面某个元素时触发的函数
onMouseOut检测鼠标指针离开页面某个元素时触发的函数
可以把函数放在.js文件夹中,通过<script src = 'name.js'></script>加载
<head>
<title>hello from javascripe</title>
<script>
function extern(){
alert("可以在页面的任何位置调用这个函数,保证已经被定义过了");
}
</script>
</head>
位于页面<head>区域的函数,相当于全局函数。
alert("8度:"+C(8));
var answer;
confirm("are you happy to continue?");
answer = prompt("what is you full name?");
answer = prompt("what is you full name?","wqq");
document.write(answer);
alter("提示信息")向用户弹出一个信息对话框,无返回值,只有确定一个选项。
confirm("提示信息"),向用户弹出一个信息对话框,有返回值,有确定和取消两个选项。
prompt("提示信息");prompt("提示信息","默认值");弹出对话框,输入内容,按取消则返回值为null,输入姓名按确定,返回值为输入姓名,没有输入,按确定,返回值为默认值。