文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>javascript事件

javascript事件

时间:2007-06-15  来源:ozy518

javascript事件

onload and onUnload
加载和未加载

The onload and onUnload events are triggered when the user enters or leaves the page.
当用户进入或是离开页面的时候onload 和onUnload事件就会被触发。

onload事件经常 用来检测访问者的浏览器类型和版本,并以此来提供合适的页面。

它们还经常用来处理用户进入或离开时cookies的处理。例如,当有用户第一次访问你的网站时要得到对方的姓名,该信息就能保存在cookies中。下次同一访问者来到你的页面时就可以在页面上显示“欢迎您,某某某(姓名)”

onFocus, onBlur and onChange

The onFocus, onBlur and onChange events are often used in combination with validation of form fields.
这些事件经常组合起来使用在表单的验证上。

下面的例子将说明怎样使用onChange事件,当用户改变内容的时候checkEmail()函数就被激活

<input type="text" size="30"
id="email" onchange="checkEmail()">;

onSubmit(提交)

The onSubmit event is used to validate ALL form fields before submitting it.
onSubmit事件被用来校验“所有“被提交的表单

下面就是一个怎样使用onSubmit事件的例子。当用户点击提交按钮就会激活函数checkForm()。如果将要提交的值不能被接受,那就会取消提交。checkForm()函数会返回真或假。返回真的话就会提交表单,假就会取消提交:

<form method="post" action="xxx.htm"

onsubmit="return checkForm()">

onMouseOver and onMouseOut(鼠标动作)

onMouseOver and onMouseOut are often used to create "animated" buttons.
这两个事件经常用来建立”活力(动感十足)“按钮

Below is an example of an onMouseOver event. An alert box appears when an onMouseOver event is detected:
下面就是一个an onMouseOver事件的例子。当鼠标移动到连接上的时候就会出现警告框:

<a href="http://www.w3schools.com"
onmouseover="alert('An onMouseOver event');return false">
<img src="w3schools.gif" width="100" height="30">

</a>

HTML 事件

Window Events
窗口事件

Only valid in body and frameset elements.
只在body和frameset元素中才有效

Attribute
属性
Value
Description
描述
onload script Script to be run when a document loads
装载时
onunload script Script to be run when a document unloads
卸载时

Form Element Events 表单元素事件

Only valid in form elements. 在表单元素中才有效。

onchange script Script to be run when the element changes
当元素有改变时脚本会执行
onsubmit script Script to be run when the form is submitted
当表单提交时...
onreset script Script to be run when the form is reset
当表单重置时...
onselect script Script to be run when the element is selected
元素被选中时...
onblur script Script to be run when the element loses focus
元素失去焦点时...
onfocus script Script to be run when the element gets focus
元素得到焦点时...

Keyboard Events 键盘事件

onkeydown script What to do when key is pressed
当键按下时做什么
onkeypress script What to do when key is pressed and released
当键按下然后释放时做什么
onkeyup script What to do when key is released
当键释放时做什么

Mouse Events
鼠标事件

Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.
在 base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style,和 title 元素里都无效.

onclick script What to do on a mouse click
单击时...
ondblclick script What to do on a mouse double-click
双击时...
onmousedown script What to do when mouse button is pressed
按下时...
onmousemove script What to do when mouse pointer moves
移动时...
onmouseout script What to do when mouse pointer moves out of an element
鼠标移开元素时
onmouseover script What to do when mouse pointer moves over an element
鼠标在元素上方时
onmouseup script What to do when mouse button is released
鼠标释放时
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载