ie浏览器bug!仅当搜索按钮按下时工作(输入不工作)

Internet Explorer bug! Working only when search button pressed (enter not working)

本文关键字:工作 输入 按钮 bug 浏览器 搜索 ie      更新时间:2023-09-26

这是搜索引擎脚本。当我按下回车或搜索按钮时,这个脚本在所有浏览器上都可以工作,但是我在Internet Explorer上使用它时遇到了一个问题。在IE中,输出不是输入点击,而是输入搜索按钮点击:

function searchForm() {
            
            document.writeln("<form name='"search'" action='"index.html'" method='"get'">");
            document.writeln("<input type='"text'" name='"searchTxt'" style='"border:2px solid #ccc; color:#000;height:26px; width:365px; margin-bottom:0pt;'"/>");
    document.writeln("<input type='"submit'" value='"Search!'" name='"search'" onkeypress='"return runScript(event)'"style='"width:81px;height:29px;border-width:0px; cursor:pointer; font-size:0px; background-image:url(''http://i703.photobucket.com/albums/ww34/studentsicon/search.png'); '"/>");
            
            document.writeln("</form>");
        
        
        
    }

您应该将元素隐藏,然后在调用searchForm时显示它。没有必要对它进行document.writeln。使用CSS或者不透明度之类的。

编辑:Internet Explorer有很多难以置信的错误。你们管它们叫"bug",微软管它们叫"特性",我们其他人管它们叫"咳咳使用Chrome/Firefox"。