document.getElementById(...)' 为空或不是对象 [后续]

木头是猫 2008-01-24 03:29:03
http://topic.csdn.net/u/20080124/14/b4f14d93-2762-42de-834c-9135646e06d9.html?seed=1155407886

====================代码==========================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> </title>
</head>
<body>
<form name=form1>
<input name="key" id="key" value="">
<input name="text2">
</form>
</body>
</html>
<SCRIPT language=javascript>
document.getElementById('key').focus();
</script>
====================代码=============================

该页面的作用目的是当刷新进入该页面,即光标自动停留在key的input里

当用程序window.location.href='"&request.servervariables("http_referer")&"'刷新时,光标的位置正常显示在指定位置

当用鼠标点中页面后,光标即消失,这个还好,但之后不管用F5或右键刷新,光标均无法出现在指定的位置,不再显示

此问题何解?
...全文
192 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
木头是猫 2008-01-24
  • 打赏
  • 举报
回复
TO hanpoyangtitan : 哈哈 你的方法 正确
什么都不能 2008-01-24
  • 打赏
  • 举报
回复
<script type="text/javascript" defer="defer">
poko_518 2008-01-24
  • 打赏
  • 举报
回复
<body onload="javascript:document.getElementById('key').focus();">

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧