开发者

change window location when iframe location is changed

Is there a way to make it so that if the page inside an iframe is not the src, then it w开发者_如何学运维ill change the parent page to the url the iframe is trying to go to? Something like this:

<script>
function redir() {
    if(document.getElementById("myiframe").src != 'http://www.google.com'){
        window.location = document.getElementById("myiframe").location
    }
}
</script>
<iframe src="http://www.google.com/" id="google" onload="redir()"></iframe>


No.

Per the same-origin policy, the parent page is not allowed to get any information about what's going in the iframe, unless the pages are on the same domain.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜