【发布时间】:2019-01-06 02:44:35
【问题描述】:
我需要在 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 google”中的点击,则在 parent.php 中显示“google .com”或在“转到 facebook”中显示“facebook.com”
我需要在 javascript(或 JQuery)中完成这项工作
【问题讨论】:
标签: javascript jquery