I’m using an iframe to integrate two of our customer’s apps. I’d like the iframe’s location to persist even when the top level window is refreshed.
Example:
- user loads http://myserver/main.page?target=‘sub.page’ in his browser
- my Javascript code sets the source of the iframe to ‘sub.page’
- user clicks a link within the iframe and the iframe’s source becomes ‘othersub.page’
- user clicks a link within the top level window , outside of iframe, that links to http://myserver/main.page
- Javascript somehow automatically updates the iframe’s source back to ‘othersub.page’
I can workout all the logic I need to take the iframe update actions and pass variables around. My issue is how to track the iframe’s src value.
I need a way to detect that the iframe’s src has changed. The only thing I can think of is ‘polling’ the value. I’d be interested to find out if someone has a better idea.
You can also add a ‘load’ event handler to this frame. Every time this event occurs, you would store the framed documents’ location in a cookie.
IIRC, when the content of an iframe changes, the SRC attribute doesn’t change. IMO, you have to read the location of the document.