簡體   English   中英

腳本僅在Internet Explorer上不起作用?

[英]Script not working on Internet Explorer only?

我的標頭中有這樣的功能

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=';

}

因此,現在當我調用此功能時,它會在Google Chrome,Firefox和現代瀏覽器中響應,但不能在Internet Explorer中響應。

你們中的任何人都可以相應地修改代碼嗎?

感謝您。

對我有用-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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM