首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js中应用document输出信息时,总是有进度条

2012-10-08 
js中使用document输出信息时,总是有进度条???? /body??? /html 在firefox下,显示正常,但是进度条总显

js中使用document输出信息时,总是有进度条

?

??? </body>???
</html>

在firefox下,显示正常,但是进度条总显示正在加载。

后来发现是我忘了关闭document;

写到当前的文档

<html><head><title>write example</title><script type="text/javascript">function newContent(){alert("load new content");document.open();document.write("<h1>Out with the old - in with the new!</h1>");document.close();}</script></head><body onload="newContent();"><p>Some original document content.</p></body></html>
写的新打开的文档,或者 iframe

<html>

<head>

<title>Write to IFRAME </title>

</head>

<body>

<iframe width="50%" height="100" id="iframe1" src=""></iframe>

<script language="JavaScript">

<!–

var str = ‘Hello I am sending this to <b>IFRAME</b>’;

// NO IE

if (!document.all) {

????? var ifr1 = document.getElementById(‘iframe1′);

????? ifr1.contentWindow.document.open();

????? ifr1.contentWindow.document.write(str);

????? ifr1.contentWindow.document.close();

}

// IE

else {

document.frames[0].document.open();

document.frames[0].document.write(str);

document.frames[0].document.close();

}

//–>

</script>

</body>

</html>

?

这里还有个比较复杂的例子等等研究一下

<html>

<head>

<title>Write to IFRAME </title>

</head>

<body>

<script language="javascript">

var txt="";

function handleErr(msg,url,l)

{

txt="There was an error on this page.nn"

txt+="Error: " + msg + "n"

txt+="URL: " + url + "n"

txt+="Line: " + l + "nn"

txt+="Click OK to continue.nn"

alert(txt)

return true

}

onerror=handleErr

function loadExternal(url) {

? var ifr1 = document.getElementById(‘srcFrame’);

? if (ifr1) {

????? ifr1.contentWindow.document.location = url;

??? //window.frames['srcFrame'].location? = url;

??? return false;

? }

? return true;

}

function GetInnerHTML () {

????? var str = null;

????? if (!document.all) {

??????????? var ifr1 = document.getElementById(‘srcFrame’);

????????????????? str = ifr1.contentWindow.document.documentElement.innerHTML;

????? }

????? else {

????????????????? str = window.frames['srcFrame'].document.body.innerHTML;????????????
????? }

????? return (str);

}

function displayExternal() {

????? var str = GetInnerHTML ();

????? if (!str) { alert (‘Could not read contents of source iframe’); return; }

????? if (!document.all) {

??????????? var ifr1 = document.getElementById(‘trgFrame’);

??????????? ifr1.contentWindow.document.open();

??????????? ifr1.contentWindow.document.write(str);

??????????? ifr1.contentWindow.document.close();

????? }

????? // IE

????? else {

??????????? window.frames['trgFrame'].document.body.innerHTML = str;

??????????? /*

??????????? ifr1.document.open();

??????????? ifr1.document.write(str);

??????????? ifr1.document.close();

??????????? */

????? }

}

</script>

<br>SRC FRAME

<br><input type="button" value="Load Local Page" onclick="(loadExternal(‘file.htm’));">

<br><input type="button" value="Load Yahoo !" onclick="(loadExternal(‘http://www.yahoo.com’));">

<br><iframe width="50%" height="100" id="srcFrame" src=""></iframe>

<br>TRG FRAME

<br><input type="button" value="Update Target Page" onclick="displayExternal();">

<br><iframe width="50%" height="100" id="trgFrame" src=""></iframe>

<script language="JavaScript">

</script>

</body>

</html>

?

引文地址:http://www.chuan.shanghuo.net/wordpress/?p=165

热点排行
Bad Request.