internet explorer -在IE中使用php头位置搜索查询不工作


internet explorer - search query in IE with php header location won't work

再次感谢您的帮助,因为那个该死的IE快把我逼疯了…

我的问题->我在我的网站上有一个搜索框,在Chrome, Safari, Mozilla中,你可以输入搜索查询并按下按钮进行搜索…到目前为止运行良好。你会被重定向,你会得到一个结果。

但是该死的IE就是没有做它应该做的。它打开一个新的空白页(什么是正确的),然后显示你来自的同一页:-/

这是我的代码…正如我所说,在所有其他浏览器中都可以正常工作!

HTML:

<form target="_blank">
    <input type="text" name="searchbar" size="40" maxlength="40"> 
    <input class="button" type="submit" name="abc" value="Search now"
      formaction="php/abc.php" formmethod="get"> </form>

和abc.php:

<?php
if (!empty($_REQUEST['searchbar']))
{
$url = array(
    'Search now'=>'http://www.mywebsite.org/search?q=__keywords__');
header('Location:'.str_replace('__keywords__',preg_replace('/(' )+/', '+', trim($_REQUEST['searchbar'])),$url[trim($_REQUEST['abc'])]));
die();
}
else
{
die();
}
?>

我还在学习,试图变得更好…所以请不要欺骗我:)

谢谢!

action属性添加到FORM标签中。我不确定formaction属性在任何地方都受支持…

<form target="_blank" method="get" action="php/abc.php">
    <input type="text" name="searchbar" size="40" maxlength="40"> 
    <input class="button" type="submit" name="abc" value="Search now"> 
</form>

谢谢你的帮助…我试了又试……解决方法很简单;)

给所有有同样问题的人:

只需将这段代码添加到您的提交输入中:

输入类型="提交"
onclick="this.form.action='whatever.php';this.formsubmit();" name="abc" value="立即搜索"
formmethod = "得到">

现在可以在IE中工作!

干杯!