0

这是一个开始于

我创建了一个 JavaScript 来根据复选框选择将文本输入到 MediaWiki 搜索框中。这现在适用于 Firefox 和 Internet Explorer。但不在谷歌浏览器中。

在 Chrome 中,搜索框已正确填充(使用上述 JavaScript),但在按下搜索按钮时搜索框为空白(空)。这意味着搜索 URL 也是空白的,这反过来意味着只显示默认的 MediaWiki 搜索页面。

Chrome对 FF 和 IE 没有的代码做了什么- 我该如何解决这个问题?

4

1 回答 1

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();

它有效,但我不知道为什么。

于 2012-05-29T15:43:44.720 回答