鼠标在网页加载成功后自动移到一个指定的区域,有JavaScript怎么实现,哪位大哥帮助小弟下。

解决方案 »

  1.   

    额  能具体点吗  我对JavaScript不太熟悉
      

  2.   

    你指的是焦点吗,比如一个输入框,就像百度一样,打开页面后,鼠标定位到搜索栏中如果是用jquery的话,jquery自行准备,这个就不给你发了,呵呵
    <!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>
    <script src="jquery-1.4.2.min.js"></script>
    <script>
    $(function(){
    $("#abc").focus();    
    });
    </script></head><body>
    <input id="abc" type="text"  /></body>
    </html>同时这个方法也适用于其他元素<!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>
    <script src="jquery-1.4.2.min.js"></script>
    <script>
    $(function(){
    $("#ee").focus();    
    });
    </script>
    <style type="text/css">
    <!--
    #dd {
    height: 800px;
    margin-bottom: 10px;
    border: 1px solid #000;
    }
    #ee {
    border: 1px solid #F00;
    height: 200px;
    }
    -->
    </style>
    </head><body>
    <input id="abc" type="text"  />
    <div id="dd">这里是DD</div>
    <div id="ee">这里是EE</div>
    </body>
    </html>
      

  3.   

    这个一般input标签比较明显比如<!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>5_14</title>
    <script>
    function test(){
    document.getElementById("textbox1").focus();
    }
    </script>
    </head><body onload="test()">
    <input type="text" id="textbox1" />
    <input type="text" id="textbox2" />
    </body>
    </html>