3
我有嵌套的iframe,我想使用內部框架的onload函數。例如:在另一個iframe中的iframe的負載函數
<script type="text/javascript">
var testing = 'test';
var curFrames;
var curUrl;
var mFrames;
var cFrame;
var editor;
var editor2;
window.onload=CodeOnLoad;
//Javascript that runs on load
function CodeOnLoad() {
curFrames=document.getElementsByTagName("frame");
console.log(curFrames[0])
//onload for 1st frame
curFrames[0].onload = getInside;
function getInside() {
//onload for second frame - Not working
curFrames[0].contentDocument.getElementByid('the_iframe').onload = finalFrame;
}
function finalFrame() {
curUrl= curFrames[0].contentDocument.getElementById("the_iframe").src;
console.log(curUrl);
if (curUrl.indexOf("post")!=-1)
{
mFrames=document.getElementsByTagName("frame");
cFrame = mFrames[0].contentDocument.getElementById('the_iframe');
editor = cFrame.contentWindow.tinymce.activeEditor;
console.log(editor);
}
}
}
</script>
碼(第二個回調):
curFrames[0].contentDocument.getElementByid('the_iframe').onload = finalFrame;
從不執行。
可以這樣做嗎?
我想確保在執行任何代碼之前加載所有幀。
感謝