我需要在javascript (或JQuery)中检测子窗口选项卡中的实际url。
示例:
parent.php
<script type="text/javascript">
function openInNewTab(url) {
var child = window.open(url, '_blank');
child.focus();
var timer = setInterval(checkChild, 500);
function checkChild() {
document.write("Show here the location.hostname from child window");
}
}
</script>
<button onclick="openInNewTab('//mypage.com/child.php');">Open Child</button>
child.php
<a href="//google.com">Go to google</a>
<a href="//facebook.com">Go to facebook</a>
如果用户打开child.php,在parent.php "mypage.com“中显示,但如果用户按下"go to parent.php ”显示在parent.php "google.com“或在"go to ”显示中点击
我需要在javascript (或JQuery)中进行此工作。
发布于 2018-07-30 04:04:25
尝尝这个
function openInNewTab(url) {
var child = window.open(url, '_blank');
child.focus();
var timer = setInterval(function(){
checkChild(child);
}, 500);
function checkChild(child) {
document.write(child.location.href , " ");
}
}
https://stackoverflow.com/questions/51583974
复制相似问题