2016-03-29 133 views
-1

請幫助使其工作。它總是指「404未找到」頁面。請參閱另一頁

enter image description here

function GoTo(){ 
 

 
     var input_1 = $("input[name='keyword']").val(); 
 
     var input_2 = $("input[name='location']").val(); 
 

 
     if(input_1 !== "" || input_2 !== "") 
 
     { 
 
      window.location.href = "page2.html"; 
 
     } 
 
    }
<form method="post"> 
 
     
 
       <button class="btn search">Search</button> 
 
    
 
    </form>

+0

只是比較預期的URL(通過打開的預期頁)與實際URL(通過執行功能來看,在地址欄)。這兩者有什麼區別?通過[編輯]告訴我們你的問題。 – Xufox

+0

你應該將完整的url設置爲location.href而不僅僅是文件名嗎? – Tapani

回答

0

主要問題是內部基地我在頁面中使用的標籤。此外,我已經改變了我的js代碼:

<script> 
 
    $('.search').click(function(event){ 
 
     event.preventDefault(); 
 
     window.location.href='./grid.html'; 
 
    }); 
 
</script>

1

,只需加上 「/」 你路段始所以這將是相對於您根

window.location.href= "/page2.html" 
+0

它不起作用。 – Maria