<script type="text/javascript">
var n;
function c()
{
n.document.body.innerHTML = "11111";
}
function t()
{
n = window.open("2.html");
n.onload = c();
}
</script><div onclick="c()">parent window</div>执行后发现不能修改2.html的内容,为何,是否有安全限制,现在被打开的窗口是在其他网站的,能否修改其内容
var n;
function c()
{
n.document.body.innerHTML = "11111";
}
function t()
{
n = window.open("2.html");
n.onload = c();
}
</script><div onclick="c()">parent window</div>执行后发现不能修改2.html的内容,为何,是否有安全限制,现在被打开的窗口是在其他网站的,能否修改其内容
你这样写等于是把c()执行后的返回值赋给了n.onload
JS的事件绑定是 n.onload = c;
window.open("2.html");并没有跨域,不存在安全问题