function ToDefiniteURL(){
  switch (document.all.strURL.value) {
   case "1":
       window.location.ref="1.htm";break;
   case "2":
       window.location.ref="2.htm";break;
   default :
       window.location.ref="3.htm";break;
  }
}
<input type='text' name='strURL' onblur='javascript:ToDefiniteURL()'>
-----------
没测试

解决方案 »

  1.   

    <script>
    function tourl(e){
      switch (e){
        case "1":
          location.href="1.html";
          break;
       case "2":
          location.href="2.html";
          break;
       default:
          location.href="3.html";
          break;
      }
    }
    </script>
    <input type="text" name="url">
    <input type="sbumit" value="提交" onclick="tourl('url.value')"> 
      

  2.   

    <script > 
    function tourl(e){ 
      switch (e){ 
        case "1": 
          location.href="1.html"; 
          break; 
       case "2": 
          location.href="2.html"; 
          break; 
       default: 
          location.href="3.html"; 
          break; 
      } 

    </script > 
      <input type="text" name="url" > 
      <input type="submit" name="Button" id="Button" value="提交" onclick="tourl( 'url.value ')" />
    不管第一个文本框输入什么,点击后都转向3.html  <script > 
    function ToDefiniteURL(){
      switch (document.all.strURL.value) {
       case "1":
           window.location.ref="1.htm";break;
       case "2":
           window.location.ref="2.htm";break;
       default :
           window.location.ref="3.htm";break;
      }
    }
    </script > 
      <input type= 'text ' name= 'strURL ' onblur= 'javascript:ToDefiniteURL() ' >
    点击后毫无反映。
      

  3.   

    window.location.ref="1.htm";break; 
    改成:
    window.location.href="1.htm";break; 
    注意红色部分.
      

  4.   

    SORRY,5楼的更正是正确的,我疏忽了,汗~
    onblur是失去焦点,文本框输入后要点一下空白处
      

  5.   

    <script  >  
    function ToDefiniteURL(){ 
      switch (document.all.strURL.value) { 
       case "1": 
           window.location.ref="1.htm";break; 
       case "2": 
           window.location.ref="2.htm";break; 
       default : 
           window.location.ref="3.htm";break; 
      } 

    </script  >  
       <input type=  'text  ' name=  'strURL  ' onblur=  'javascript:ToDefiniteURL()  '  >
    依然提示网页上有错误
      

  6.   

       <script  >  
    function ToDefiniteURL(){ 
      switch (document.all.strURL.value) { 
       case "1": 
           window.location.href="1.htm";break; 
       case "2": 
           window.location.href="2.htm";break; 
       default : 
           window.location.href="3.htm";break; 
      } 

    </script  >  
       <input type=  'text  ' name=  'strURL  ' onblur=  'javascript:ToDefiniteURL()  '  >
    IE 依然提示网页上有错误
      

  7.   

       <script  >  
    function ToDefiniteURL(){ 
      switch (document.all.strURL.value) { 
       case "1": 
           window.location.href="1.htm";break; 
       case "2": 
           window.location.href="2.htm";break; 
       default : 
           window.location.href="3.htm";break; 
      } 

    </script  >  
       <input type=  'text  ' name=  'strURL  ' >
       <input type="submit" name="Button" id="Button" value="提交" onclick="javascript:ToDefiniteURL()  " / >
    还是提示网页上有错误
      

  8.   

    <script  >  
    function tourl(e){  
      switch (e){  
        case "1":  
          location.href="1.html";  
          break;  
       case "2":  
          location.href="2.html";  
          break;  
       default:  
          location.href="3.html";  
          break;  
      }  
    }  
    </script  >  
       <input type="text" name="url"  >  
       <input type="submit" name="Button" id="Button" value="提交" onclick="tourl(url.value)" / >成功了,问题出在 onclick="tourl(url.value)" ;而不是onclick="tourl(  'url.value  ')" 
      

  9.   

    function getBack(txtid) //txt1是文本框的ID
    {
    document.getElementById("btn1").onclick=function()
    {
    var val=document.getElementById(txtid).value;
    window.location.href=val+".html";
    }
    }