Reputation: 8162
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:
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.
Upvotes: 1
Views: 1575
Reputation: 1017
The load event will tell you when a new page loaded in the iframe, but as you say, you wont have permission to read the src property.
If the content of the iframe could load another iframe, which loads a page from the same domain as the root page, then this inner page can call javascript on the root page (since they are on same domain), and pass on info like the src string you wanted. Example
Upvotes: 0
Reputation: 18522
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.
Upvotes: 1