function tt(){
  if(window.event.keyCode==13)
    window.location=document.forms[0].txt.value;
}<input onkeyup="tt()" name=txt>

解决方案 »

  1.   

    function tt(){
      if(window.event.keyCode==13)
        window.location.href=document.forms[0].txt.value;
    }<input onkeyup="tt()" name=txt
      

  2.   

    <script>
    function tt(){
      if(window.event.keyCode==13)
        window.location=document.all.txt.value;//something error here,should be this.//or window.open(document.all.txt.value,'','')
    }
    </script>
    <input onkeyup="tt()" name=txt>
      

  3.   

    //添加了容错处理的
    <script>
    function tt()
    {
    if(window.event.keyCode==13)
    {
    var url=new String(document.all.txt.value);
    url=url.toLowerCase()
    var s=new String("http://")
    if(url.indexOf(s)<0)
    url=s.concat(url)
    window.open(url,"Null","")    
    }
    }
    </script>
    <input onkeyup="tt()" name=txt>