2012-01-12 117 views
1

沒有工作,我有我的網站上,似乎不能在Chrome也不火狐正常運行搜索文本框......但在IE瀏覽器(所有版本)工作...搜索領域的Chrome

有什麼我做錯了?我無法找到爲什麼價值沒有被傳遞給「搜索者」應用程序。

<div class="searchbox" id="searchbox"> 
    <script type="text/ecmascript"> 
     function RunSearch() { 
      window.location = "http://searcher.myexampledomain.com:8765/query.html?ql=&amp;col=web1&amp;qt=" + document.getElementById("search").value; 
     } 
    </script> 
     <div class="formSrchr"> 
      <input type="text" size="20" name="qt" id="search" value="Search" onfocus="if(this.value == 'Search') {this.value=''}" onblur="if(this.value == ''){this.value ='Search'}" /> 
      <input type="hidden" name="qlOld" id="qlOld" value="" /> 
      <input type="hidden" name="colOld" id="colOld" value="web1" /> 
      <input type="image" name="imageField" alt="search" src="/_images/search-mag.gif" onclick="RunSearch();" /> 
     </div> 
</div> <!-- /searchbox --> 

回答

4

您不應該在您的URL中對&進行HTML編碼。

這就夠了;

window.location.href = "http://searcher.myexampledomain.com:8765/query.html?ql=&col=web1&qt=" + document.getElementById("search").value;

+1

OP應該考慮使用'window.location.href'而不是'window.location'在下面的問題中指出:http://stackoverflow.com/questions/2345807/window-location-does-not-work-on-chrome-browser – xandercoded 2012-01-12 16:16:04

+0

這是&符號...謝謝..將這兩個實例更改爲不編碼符號,現在它可以工作。我能跟進這個問題嗎?爲什麼當我剛剛點擊「輸入」按鈕,它不會再提交,對於Chrome或FF,但在IE中工作? – 2012-01-12 16:37:29

+0

您的表單不包含任何「提交」按鈕。 ''。 – Stefan 2012-01-12 16:40:54

2
<script type="text/ecmascript"> 

也許是這個問題,並引起瀏覽器之間的反應的差異。嘗試改變它在:

<script type="text/javascript">