Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IFRAMES and JS

Status
Not open for further replies.

ggriffit

Programmer
Joined
Oct 25, 2002
Messages
1,578
Location
GB
Can someone explain why this works in IE and not in NN, hopefully with a workaround ;-)

<html>
<body>
<iframe name=&quot;test&quot; id=&quot;test&quot;></iframe>
<form>
<input type=&quot;button&quot; onclick=&quot;doit()&quot;>
</form>
<script language=&quot;javascript&quot;>
function doit()
{
document.test.document.open(&quot;text/html&quot;);
document.test.document.write(&quot;HELLO&quot;);
document.test.document.close();
}
</script>
</body>
</html>
 
I don't think that <IFRAME> element is supported by Netscape. The workaround is to use frames in stead of iframes.
 
IFrames are support in NN6 and higher as they appear in my browser, not sure why the code does not work though.
 
ggriffit,

This worked in NN7.1 give it a try:

Code:
<html><body>
<iframe name=&quot;test&quot; id=&quot;testa&quot;></iframe>
<form>
<input type=&quot;button&quot; onclick=&quot;doit()&quot;>
</form>
<script language=&quot;javascript&quot;>
function doit()
{
   parent.test.document.open(&quot;text/html&quot;);
    parent.test.document.write(&quot;HELLO&quot;);
    parent.test.document.close();
}
</script></body></html>

2b||!2b
 
I am glad you asked, it is much more versatile than
what I thought, this also works in NN7.01

I was just like LV(thought IFRAME was not supported).

But NN handles it very well look at this:

Code:
<html><head>
<script language=&quot;javascript&quot;>
var diff = false;
function mkit(){
    parent.test.document.open(&quot;text/html&quot;);
    parent.test.document.write('<div id=&quot;txt&quot;></div>');
    parent.test.document.close();
}
function wrtit(str){
    parent.test.document.getElementById('txt').innerHTML = str;
}
</script></head>
<body onLoad=&quot;mkit()&quot;>
<iframe name=&quot;test&quot; id=&quot;testa&quot;></iframe>
<form>
<input type=&quot;button&quot; value=&quot; Hello &quot; onclick=&quot;wrtit('Hello')&quot;>
<input type=&quot;button&quot; value=&quot; Goodbye &quot; onclick=&quot;wrtit('Goodbye')&quot;>
</form>
</body></html>

I don't have any NN older version, where is IFRAME support
begun, I wonder.

2b||!2b
 
IFRAME's were origionaly supported by microsoft. Netscape used LAYER's.
 
Got the stuff working, so thanks for that, but only when the IFRAME is already present on the page, if I try and add it using document.write before I use the above to populate it, I get the IFRAME created, but an error on population :

window.<iframe name> has no properties

Any solutions as this works fine in IE ?
 
second problem is that after populating it on NN6+ the updated data does not appear immediately, I need to refresh the IFRAME for that to happen, although when I do that using the reload() function I lose my link form the IFRAME to the main window and get the following error :

Error: uncaught exception: Permission denied to get property Window.jumpto

Although if I take out the auto refresh and do it manually using the browser button there is no problem and IE works fine regardless ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top