alert后页面焦点问题 各位前辈: 在页面中alert后,点击完alert的确定按钮后 如何让页面中的一个图片链接获得焦点呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 当前对象.focus()就可以了 我是这样写的 appage.onclick=function(){ alert("请点击重新填写按钮,开始新的试算!"); document.getElementById("reSet").focus(); }但是不管用 reSet 还是没有获得焦点 试试这样行吗?document.getElementById("reSet").setfocus; <!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=gb2312" /><title>无标题文档</title></head><body><button id="show" onclick="setFocus();">点我</button>11<input name="ss" id="ss" type="text" /><script language="javascript" > //alert("@@"); function setFocus() {alert("@@"); document.getElementById('ss').focus() }</script></body></html> document.getElementById("reSet").setfocus; document.getElementById("reSet").setfocus; document.getElementById("reSet").focus(); onclick 是鼠标单击事件,你按回车当然没反应,你应该加一个键按下事件onkeydown="javascript:if (event.keyCode==13) 你的方法名();" LZ你的意思我明白,onfocus对IMG默认貌似是无效的。得给IMG加个tabindex属性,然后就可以用了<input type="button" value="点我" onclick="test();"><img id="img" tabindex="1" src="图片路径"></img><script> var obj = document.getElementById("img"); obj.onfocus = fn; function test(){ alert("点击"); obj.focus(); } function fn(){ alert("focus"); }</script> 哈哈 差不多吧 focus 好象是多IMG 无效,我后来在<a id="reSet">这里边用了 就可以了 hibernate 一对多 查询问题 求Java上传图片代码 【求助】开发是一个日积月累的过程 JAVASCRIPT动态排序 如果利用编程从一个网页直接登陆到另一个网页? linux 下浏览器不能正确执行applet,试了很多方法还是不行? 用jsp删除Access数据出错 print顺序 如何在resin和tomcat中配置Servlet链? 一年前做了一个论坛(仿古城热线BBS),中间有一个全组件化的权限管理系统(应用设计模式),想整理一下,公开源码,有人要吗? dwr SESSION问题!在线等待! JavaMail 高手来!
当前对象.focus()
就可以了
我是这样写的 appage.onclick=function(){
alert("请点击重新填写按钮,开始新的试算!");
document.getElementById("reSet").focus();
}
但是不管用 reSet 还是没有获得焦点
document.getElementById("reSet").setfocus;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<button id="show" onclick="setFocus();">点我</button>
11<input name="ss" id="ss" type="text" />
<script language="javascript" >
//alert("@@");
function setFocus()
{alert("@@");
document.getElementById('ss').focus()
}
</script></body>
</html>
onkeydown="javascript:if (event.keyCode==13) 你的方法名();"
<input type="button" value="点我" onclick="test();">
<img id="img" tabindex="1" src="图片路径"></img>
<script>
var obj = document.getElementById("img");
obj.onfocus = fn;
function test(){
alert("点击");
obj.focus(); }
function fn(){
alert("focus");
}
</script>
哈哈 差不多吧 focus 好象是多IMG 无效,我后来在<a id="reSet">这里边用了 就可以了