I have an iFrame which has several links on the page which is inside the iFrame.

From the outside document, how can I tell if the page in the iFrame has been redirected?

<body>
    <script>
        if(somePage.html has been redirected) {
            //do something
        }
    </script>

    <iframe src="somePage.html">...</iframe>
</body>
有帮助吗?

解决方案

Give the iframe an id and try putting an load() function in the document.ready() handler:

$(document).ready(function () {
    $("iframeID").load(function () {
        //iframe loaded
        alert(this.contentWindow.location);
    });
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top