[英]JavaScript popup url
How can i get url of a popup opened by JS. 我如何获得由JS打开的弹出窗口的URL。 Here is my code:
这是我的代码:
var _url = 'someurlhere';
var popupwindow = window.open(_url, "Popup", 'width=800, height=600');
var _this = this;
var pollTimer = window.setInterval(function() {
try {
console.log(popupwindow.document.URL);
} catch(e) {
console.log(e.message);
}
}, 500);
but I'm getting a Cannot read property 'URL' of undefined
error on line with console.log(e.message). 但我得到一个
Cannot read property 'URL' of undefined
错误的Cannot read property 'URL' of undefined
与console.log(e.message)一致。 Why ? 为什么?
It won't work because you are using a url that is a different domain than the page you are running the script on. 它不起作用,因为您使用的URL与您运行脚本的页面不同。 This is a violation of the " same origin policy ".
这违反了“ 同源政策 ”。 IOW it is XSS, not allowed.
它是XSS,不允许。
使用popupwindow.location.href
而不是popupwindow.document.URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.