【发布时间】:2010-07-05 04:43:26
【问题描述】:
是否可以使用document.createElement("iframe"); 创建一个 iframe,然后在 iframe 的窗口对象中设置一个变量,例如命名空间?
我尝试过这样做:
var Namespace = {};
var iframe = document.createElement("iframe");
iframe.src = "page.html";
document.body.appendChild(iframe);
var iwin = iframe.contentWindow || iframe.contentDocument.defaultView;
iwin.Namespace = Namespace;
但在 page.html 中,我尝试记录 Namespace 并引发未定义的错误。
【问题讨论】:
标签: javascript iframe window namespaces