0

无法弄清楚为什么在搜索框中进行的查询没有保留在 IE 中(当然)。有人可以在IE中打开下面的链接吗

http://www.adhuntr.com/p/results.html?ie=UTF-8&q=ipad+mini&min=&max=&l=all&c=all&t=&p=

4

2 回答 2

1

该错误是由于您的addLoadEvent()函数引起的,仅从fillSearchBox()IE 开发控制台调用会正确触发此函数并使用查询填充输入框。

特别是,错误在此调用中:addLoadEvent(fillSearchBox);

我尝试在 jsFiddle 中使用 addLoadEvent 函数的更新建议,没有成功。

由于您使用的是 jQuery,因此您可以使用它来代替代码。jsFiddle中的示例:

jQuery(document).ready(function () {
   fillSearchBox()
});

顺便说一句,你有一个错字input.result,这就是为什么当你选择一个建议时搜索不会自动提交的原因:

input
    .attr ("autocomplete", "off")
    .autocomplete ("http://clients1.google.com/complete/search", options)
    .result (function () { searchform.submit(); }); //<== typo in this line, should be submit

您确实应该将所有内联代码移至外部文件,页面中有大量内联 JavaScript 和 CSS,每次页面加载时都需要下载。

于 2013-05-19T08:08:01.513 回答
0

我猜测保留,您的意思是在您输入或建议时出现在搜索栏中?嗯,这可能是因为旧版本的 IE 即 6,7 不支持 AjaxXMLHttpRequest()对象,因此......您必须更改您的 ajax 代码,即少于一行,以检查window.ActiveXObjectIE。通过做

if(window.XMLHttpRequest){
        xmlhttp = new XMLHttpRequest(); }
        else if(window.ActiveXObject) {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        else {
            alert('Please update your browse, to see Ajax in Action :) ');
    }
于 2013-05-19T00:13:46.737 回答