2010-09-22 53 views
0

我有這樣的功能在我的頭腳本不適用於Internet Explorer?

function bingframe() { 

var iframe = document.getElementById('bframe'); 
iframe.src = 'http://www.bing.com/search?q=' + document.searchForm.search.value.replace(/ /g,'+') + '&go=&form=QBLH&filt=all&qs=n&sk='; 

} 

所以,現在當我調用此函數它在谷歌Chrome,火狐和現代瀏覽器的響應,但不是Internet Explorer。

您能否相應地修改代碼?

感謝你。

+0

其中IE的版本,您使用的? IE6,IE7,IE8或IE9 beta ......他們都不一樣。 IE8和IE9測試版最接近FF和Chrome。 – webdad3 2010-09-22 14:24:58

回答

1

對我的作品 - IE8

<html> 
    <head> 
    <title></title> 
<script> 
function bingframe(theForm) { 
    var iframe = document.getElementById('bframe'); 
    var url = 'http://www.bing.com/search?q=' + escape(theForm.search.value).replace(/ /g,'+') + '&go=&form=QBLH&filt=all&qs=n&sk='; 
    iframe.src = url; 
    return false 
} 
window.onload=function() { 
    document.forms[0].search.focus(); 
} 
</script> 
</head> 
<body> 
<form name="searchForm" onSubmit="return bingframe(this)"> 
<input type="text" name="search" value="" /> 
<input type="submit"> 
</form> 
<iframe id="bframe" src="about:blank" width="100%" height="100%"></iframe> 
</body> 
</html> 

但是這樣做了 - - 沒必要的腳本:

<html> 
<head> 
<title></title> 
<script> 
window.onload=function() { 
    document.forms[0].q.focus(); 
} 
</script> 
</head> 
<body> 
<form name="searchForm" action="http://www.bing.com/search" target="bframe"> 
<input type="text" name="q" value="" /> 
<input type="hidden" name="go" value="" /> 
<input type="hidden" name="form" value="QBLH" /> 
<input type="hidden" name="filt" value="all" /> 
<input type="hidden" name="qs" value="n" /> 
<input type="hidden" name="sk" value="" /> 
<input type="submit"> 
</form> 
<iframe name="bframe" src="about:blank" width="100%" height="100%"></iframe> 
</body> 
</html> 
相關問題