سؤال

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