------------------------js事件
必须使用的事件
1.超链接事件
2.表单的提交
3.表单内部界面对象的交互
-----------onclick事件
[javascript] view plain copy
- <script language="javascript">
- function a() {
- window.alert("hello!");
- }
[javascript] view plain copy
- <form name="form1" action="" method="post">
- <input type="button" name="button1" value="点击" onclick="a()" /> //点击按钮时弹出警告框
- </form>
---------onchange
[javascript] view plain copy
- <script language="javascript">
- function a() {
- window.alert("asd的值发生了变化!");
- }
- </script>
[javascript] view plain copy
- <form name="form1" action="" method="post">
- <input name="asd" type="text" value="asd" onchange="a()" /> //当文本框的值变化时弹出警告框,事件中调用函数
- </form>
事件中直接引用语句:
[javascript] view plain copy
- <form name="form1" action="" method="post">
- <input name="asd" type="text" value="asd" onchange="alert('asd的值改变为:' + this.value)"
- />
-------------------onselect
[javascript] view plain copy
- <form name="form1" action="" method="post">
- <textarea name="textarea1" rows="10" cols="40" onselect="alert('该文档不能被复制')" />
- Windows对象(上)(下)
- 5.7.3 Location对象
- 5.7.4 History对象
- 5.7.5 Document对象
- 5.7.6 字符串对象
- 5.7.7 数学对象
- 5.7.8 时间对象
- 5.7.9 数组对象
- 5.7.10自定义对象
- </textarea> //当选择该文本区域的文字时弹出警告框
- </form>
------------------onLoad(图像或页面结束载入时产生)
[javascript] view plain copy
- function MM_openBrWindow(theURL, winName, features) {
- window.open(theURL, winName, features);
- }
[javascript] view plain copy
- <body onLoad="MM_openBrWindow('images/1.jpg','图片','toolbar=yes,width=800,height=800')">
- </body>
----------------onUnload
[javascript] view plain copy
- <body onUnload="alert('thanks for visiting')">
- <a href="http://www.baidu.com">baidu</a>
- </body>
-------------------onmouseover和onmouseout
[javascript] view plain copy
- <a href="http://www.baidu.com" onmouseover="alert('鼠标移上来了')">baidu</a>
- <font onmouseout="alert('鼠标移走了')">mouse</font>
作者:习惯沉淀