MozTW 討論區
https://forum.moztw.org/

contentDocument問題
https://forum.moztw.org/viewtopic.php?f=13&t=11070
1 頁 (共 1 頁)

發表人:  Me-X [ 2005-10-21, 11:18 ]
文章主題 :  contentDocument問題

本人的code 如下
<script language="javascript" >
function getIFrameDocument(aID) {
var rv = null;

// if contentDocument exists, W3C compliant (Mozilla)
if (document.getElementById(aID).contentDocument){
rv = document.getElementById(aID).contentDocument;
} else {
// IE
rv = document.frames[aID].document;
}
return rv;
}

function htmlpreview(prename){
var docu=getIFrameDocument(prename);
//document.mainform.elements[textareav].value
docu.write("a");
}
</script>
再加上一個iframe
<iframe name="previewchin" id="previewchin" frameborder="0" height="100%" scrolling="yes" align="center" src="preview.php" width="100%"> </iframe>
如果 htmlpreview('previewchin')
完全正常,而且iframe內出現了a 字。
但firefox 就一直loading,不知load 什麼,沒有停止,右下1角的processing bar 就一直只得一半,請問有沒有方法可以解決。

發表人:  Me-X [ 2005-10-21, 11:33 ]
文章主題 :  自問自答

加上一句
docu.close();在
docu.write("a");
後就可以了,不知是什麼事,但很奇怪

發表人:  Amauds [ 2005-10-21, 13:08 ]
文章主題 : 

Me-X 寫:
加上一句
docu.close();在
docu.write("a");
後就可以了,不知是什麼事,但很奇怪


正規的網頁文件寫法罷了。
例:
nFrame.document.open("text/html", replace);
nFrame.document.write("some html code");
nFrame.document.writeln(" ... ");
nFrame.document.close();

1 頁 (共 1 頁) 所有顯示的時間為 UTC + 8 小時
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/