用Javascript制作一个可自动填写的文本框(全文完)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 yjgx007 的 blog

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处http://xinyistudio.vicp.net/和作者信息及本声明  

 

ø autocomplete()的补充

autocomplete() 方法补充一下,我们先到可自动完成的文本框标记中看一下(译者注<input type=text>),autocomplete()方法将给出三个参数:作用于的文本框的对象otextbox对象,event(事件)对象。调用方法如下:

<input type=”text” onkeyup=”return autocomplete(this, event, arrvalues)” />

 

考虑到在文本框中触发onkeypress事件(译者更正:应该使用onkeyup事件,以保证字符已被输入)的第一个键的键码:

function autocomplete(otextbox, oevent, arrvalues) {

   switch (oevent.keycode) {

       ...
   }
}

 

有许多按键需要被屏蔽,如光标键,只需要在下面指定的case语句中返回true

function autocomplete(otextbox, oevent, arrvalues) {

   switch (oevent.keycode) {

本文关键:IE Opera Mozilla TextRange 浏览器检测
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top