如何用js实现鼠标焦点自动落到文本框?

来源:百度知道 编辑:UC知道 时间:2024/09/25 21:28:53
点击到A页面,鼠标焦点如何自动到 input 文本框?当鼠标点击其他位置,闲置的时候焦点也自动返回文本框,有高手做过相关的案例吗?
tz6060996 你的方法可行,但是鼠标焦点没办法移开了,如果有第二个文本框是没办法输入的,有没有完满的解决方法,一个是有没有办法限制 Text1 在其他文本框自动让出焦点不在输入状态自动跳回,另一个是假设第二个文本框Text2 用js强制抢焦点,但是我用onMouseOver="this.focus(); " 网页会出现假死

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<title>无标题页</title>
</head>
<body onload="Text1.focus();">
<input id="Text1" type="text" value="文本框" onblur="this.focus();"/>
</body>
</html>

对问题补充的答复:
如果这样的话,用下面的代码你看行吗?
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<title>无标题页</title>
</head>
<script>var b=true;</script>
<body onload="Text1.focus();" onmousemove="if(b) Text1.focus();">
<input id="Text1" type="text" value="文本框" />
<input id=&