this.r.document.writeln("<script type=\"text/javascript\">");
this.r.document.writeln(" setTimeout('parent.BindListMenu();',5000);");
this.r.document.writeln("</script>");
IE6/8 正常,IE7 不執行。
setTimeout('code()', ...) 的 eval 執行上下文有限制,建議改用函數引用:setTimeout(parent.BindListMenu, 5000);document.write 會隱式 document.open() 清空文檔。確保在頁面解析階段調用,或改用 DOM 方法:var s = document.createElement('script'); s.text = "parent.BindListMenu();"; document.head.appendChild(s);parent.BindListMenu 要求同源策略允許。IE7 對 document.domain 設置更嚴格,確保父子頁面同域且均設置 document.domain = 'base.domain'。console.log('Injecting script...');
setTimeout(function() {
console.log('Timeout fired, calling BindListMenu');
if (typeof parent.BindListMenu === 'function') {
parent.BindListMenu();
} else {
console.error('BindListMenu not found on parent');
}
}, 5000);
棄用 document.write,改用 fetch/import() 動態加載模塊,或使用 postMessage 跨框架通信。