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);
});
});
题
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);
});
});