例如在和标签中间添加了如下代码
function test()
{
var newWindow = window.open("https://segmentfault.com", "a", "width = 600,height = 400");
document.write(newWindow.location.href);
document.write(newWindow.innerWidth);
}
test();
测试后的输出结果分别为 about:blank 与 0,但按我的理解是"https://segmentfault.com"与600。不知道我的理解哪里出了问题,希望有人来讲解一下。
还有就是想问一下,如果真的是这样的话,那新窗口的URL这些属性应该怎么查询呢?
JS新手,希望得到大家的指导!
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
如果你能拿到值,也就能设置,浏览器的安全性机制不允许跨域。除非你用jsop,代理设置等针对这种问题的解决方案。