当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 模拟用户操作Input元素,不会触发相应事件

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 模拟用户操作Input元素,不会触发相应事件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 93 ::
收藏到网摘: n/a

Javascript中input元素的一个普遍规则是,只有用户的操作,才会出发input类的各种元素的对应事件,而是使用javascript的对应方法模拟用户操作,并不会触发相应的事件。
例如对于下面的表单:
<form name="form0">
<input type="button" value="按钮0" name="b0" onClick="alert('单击按钮0');">
</form>
当用户调用b0的click()方法来模拟用户单击按钮0时,按钮的onClick事件不会被触发,所以相应事件处理函数也不会被执行。只用用户真正的点击了按钮,事件才会被触发,事件处理函数才会被执行。
另:一组同名input元素的数据被提交到服务器端时,数据格式是:name=value,value,...