<head>
<script language=javascript>

function document.onkeydown()
{
   if (event.keyCode == 13)
   {
//alert("do what you want");
location.href = document.getElementById("ts").href;
   }
}
</script>
</head>
<BODY>
<FORM NAME="f">
<input type="text" name="test1"><br>
<input type="text" name="test1"><br>
<a href="http://www.sina.com.cn" id="ts">www.sina.com.cn</a>
</FORM>
</BODY>

解决方案 »

  1.   

    <script language="javascript"  type="text/javascript">

    function document.onkeydown()
    {
       if (event.keyCode == 13)
       {
    window.location.href(document.getElementById("ts").href);
       }
    }
    </script>
      

  2.   

    <!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>
    <div onmousedown="aa(this);">
    <a  id="a1" href="http://www.google.cn">google</a>
    <input type="text" onkeydown="aa(event);"/></div></body>
    </html>
    <script type="text/javascript">function aa(evt)
    {

    evt = (evt) ? evt : ((window.event) ? window.event : "")

    if(evt.keyCode == 13)
    {

    window.location.href=document.getElementById("a1").href;
    }
    }//window.location.href(document.getElementById("a1").href);
    </script>
    ----
    兼容各浏览器的