Click to See Complete Forum and Search --> : How to force refresh after iframe source code changes


probey20
February 2nd, 2006, 01:19 PM
Background: I'm modifying an application where I have access to the header and top navigation, but not to the content with the iframe in the body of the page. The iframe points to a URL (on the same domain) which is controlled by another team and I cannot modify.

I need to search for a certain value in the iframe's source code and if I find it, change the logo up in the header. I got this to work... however the iframe has a set of left navigation all its own (which I cannot control). Several of the links do not refresh the entire page (only the iframe), so my code doesn't always get executed when I want it to. It is currently called in the body onLoad event.

Question: How can I detect when the iframe source code has changed (without modifying it myself), so I can force a refresh, causing my header code to get executed again? Or... is there a way to see which link was clicked on and force a refresh, without modifying the onClick event?

Thanks!
Sarah

PeejAvery
February 2nd, 2006, 02:12 PM
You can set a variable equal to the innerHTML of the IFRAME. Now refresh the IFRAME and check to see if the new variable is the same as the old.

<script language="JavaScript">
var iframetextcur;
var iframetextprev;

function checkiframe(){
iframetextcur = IFRAMENAME.document.innerHTML;
if(iframetextcur != iframetextprev){alert("IFRAME Changed!");}
iframetextprev = iframetextcur;
setTimeout("checkiframe()", 1000);
}
</script>