Is there an event to detect URL change inside an iframe?
Let say, I have an iframe like that:
<iframe src='test.html'></ifram开发者_开发技巧e>
and in test.html, there is a button that will change its url to ...let say google.com
so, is there any way that the iframe knows there is a change in the src?
e.g. onchange or onload.. or whatever.
First of, know the facts about cross-domain policy.
Secondly, if you have control of the child iframe, you can write a script to inform it's part frame (window).
If you have control of the iframe content, you could insert a script setting an action on onbeforeunload event, like so:
<script type="text/javascript">
self.onbeforeunload = function() {alert('unloadevent in frame window');};
</script>
Be aware that onbeforeunload only works in IE and Firefox though, as far as I know.
精彩评论