我正在打开另一个网站 (google oauth2) 的弹出窗口。我加载的站点会在标题栏显示信息,所以我想监控标题栏来提取信息。但是,每当我这样做时,即使窗口确实有标题,标题也总是空白。这是我现在正在尝试的,只是为了测试。
var authWindow = null;
function popup(url) {
authWindow = window.open(url, 'Authentication', 'height=600,width=450');
if (window.focus) {
authWindow.focus();
}
$(authWindow.document).ready(monitorForAuthCode);
}
function monitorForAuthCode()
{
if (authWindow && authWindow.closed == false)
{
var code = authWindow.document.title;
$('#hash').html($('#hash').html() + code + '<br>');
setTimeout(monitorForAuthCode, 1000);
}
}
最佳答案
popup of another site (google oauth2)
由于 same origin policy,您无法阅读另一个域的内容.
关于javascript - 如何获取弹出窗口打开的窗口的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7970306/