A few days back i was working on a problem for which i had to read contents from a body tag of an iframe. I tried the normal code which any developer will use :
var bodyContent=window.frames['frameName'].document.body.innerHTML;
To my surprise it was not cross browser compatible.
It didn’t work on both IE and Firefox.
After googling i figured it out how to make it work for both IE and Firefox. Here is the code
var iFrameId = document.getElementById('frameId'); //For Firefox if ( iFrameId .contentDocument ) { alert( iFrameId .contentDocument.getElementsByTagName('body')[0]); } else if ( iFrameId .contentWindow ) { // internet explorer alert(iFrameId .contentWindow.document.getElementsByTagName('body')[0]); }
Have fun !!



























































