Click to See Complete Forum and Search --> : script error


gjiyer123456789
January 29th, 2005, 07:16 AM
I have written following piece of code.

function test()
{
document.write("<iframe name='FRM' width=0 height=0 src='http://.....(some URL)'></iframe>");

var result = FRM.document.all(0).innerHTML;
}

in the above case the execution fails. But if i add an "alert()" before var result, it works fine. Can someone help me to resolve this issue???

Dr. Script
January 29th, 2005, 11:34 AM
Reference the iframe by using the getElementsByName() HTMLCollection. Then get rid of the document.all(0):var result = document.getElementsByName('FRM')[0].innerHTML;This will fail if the source of the iframe is not the same url as the main window.

However, I would find it better to create a new iframe element, then append it to the document. However, that should work as is

Dr. Script