开发者

change window location when iframe location is changed

开发者 https://www.devze.com 2023-02-18 17:54 出处:网络
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:

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

精彩评论

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