views:

308

answers:

2

Let say, I have an iframe like that:

<iframe src='test.html'></iframe>

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.

A: 

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).

Christian Sciberras
A: 

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.

AMO