为什么谷歌浏览器清空我在MediaWiki中的搜索栏

Why is Google Chrome emptying my search bar in MediaWiki?

本文关键字:搜索栏 MediaWiki 谷歌浏览器 清空 为什么      更新时间:2023-09-26

这是一个始于

  • 使用InputBox向MediaWiki搜索查询添加额外的搜索文本,并继续
  • PHP 函数未定义错误和语法错误,</p>在生成的 HTML 中放错位置。

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

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

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

在我的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();

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