2012-05-29 20 views
0

這是與爲什麼Google Chrome會將MediaWiki中的搜索欄清空?

我創建了一個JavaScript來輸入文本到MediaWiki搜索框中,具體取決於複選框的選擇。這現在適用於Firefox和Internet Explorer。但不在Google Chrome

在Chrome中,搜索框被正確填充(使用前面提到的JavaScript),但搜索框在搜索按鈕被按下時空白(空白)。這意味着搜索URL也是空白的,這意味着只顯示默認的MediaWiki搜索頁面。

什麼是Chrome與the code FF和IE不是 - 我該如何解決這個問題?

回答

0

在我的PHP代碼,我嵌入這個JavaScript:

<script type="text/javascript">function appendAndSubmit(){var platform1 = document.getElementById('p1').checked;var platform2 = document.getElementById('p2').checked;var text = document.getElementById('searchboxInput').value;if (platform1 * platform2 >0) text = text + ' "Applies to=Platform 1.0" "Applies to=Platform 2.0"';else if (platform1) text = text + ' "Applies to=Platform 1.0"';else if (platform2) text = text + ' "Applies to=Platform 2.0"';document.getElementById('searchboxInput').value = text;document.forms['searchform'].submit();}</script> 

變量text被定義爲是什麼在尋找的表格。所以,我只是改變了最後一部分:

document.forms['searchform'].submit(); 

text.submit(); 

它的工作原理,但我不知道爲什麼。

相關問題