各位前辈: 在页面中alert后,点击完alert的确定按钮后 如何让页面中的一个图片链接获得焦点呢?

解决方案 »

  1.   


    当前对象.focus()
    就可以了
      

  2.   


    我是这样写的 appage.onclick=function(){

    alert("请点击重新填写按钮,开始新的试算!");
    document.getElementById("reSet").focus();

           }
    但是不管用 reSet 还是没有获得焦点
      

  3.   

    试试这样行吗?
    document.getElementById("reSet").setfocus; 
      

  4.   

    <!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>
      

  5.   

    document.getElementById("reSet").setfocus; 
      

  6.   

    document.getElementById("reSet").setfocus; 
      

  7.   

    document.getElementById("reSet").focus();
      

  8.   

    onclick 是鼠标单击事件,你按回车当然没反应,你应该加一个键按下事件
    onkeydown="javascript:if (event.keyCode==13) 你的方法名();"
      

  9.   

    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>
      

  10.   


    哈哈 差不多吧 focus 好象是多IMG 无效,我后来在<a id="reSet">这里边用了 就可以了