2008-06-03

iframe 的 innerhtml

我有使用mootool.js

function FRAME(id){
var i;
if ( i = $(id) ){
if (i.contentDocument) {
var d = i.contentDocument;
} else if (i.contentWindow) {
var d = i.contentWindow.document;
} else {
var d = window.frames[id].document;
}
return d;
}else return null;
}
alert(FRAME(id).body.innerHTML);

當IFRAME的內文 只有 script 時,如下:

< script >alert('z-win.com');< /script >


innerHTML 將會是空字串
若內文是
< b>z-win.com< /b>
< script >alert('z-win.com');< /script >


就會正常回傳全部內文

沒有留言: