您现在的位置是:首页 > 电脑技术查询 > web开发

IE,FireFox 设置焦点有关问题

编辑:chaxungu时间:2022-10-02 23:15:28分类:web开发

IE,FireFox 设置焦点问题
如何动态编写通用ie,fireFox设置焦点js

------解决方案--------------------
在onload调用input的focus函数
------解决方案--------------------
上面的有错,给你重来一个
HTML code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>设置默认焦点</title> <script language ="javascript"> function init(){ var ctrl=document.getElementById("UserName"); ctrl.focus(); } </script> </head> <body onload="init()" > <h1>设置默认焦点</h1> 姓名:<input type="text" id="UserName"> </body></html>
------解决方案--------------------
那你肯定能得到该对象吧,调用focus就行了
------解决方案--------------------
对象.focus()应该可以吧?
------解决方案--------------------
探讨

ie调用对象focus()方法可以,firefox不行