Click to See Complete Forum and Search --> : Javascript Iframe and applet


jbergthorson
10-06-2003, 11:53 AM
I have an html page with an iframe in it.
Within that iframe is an applet.

The html page and the applet interact via javascript and the netscape.javascript package in the applet.

I used to have the applet in a normal frame, and thus I could access the applet by code like:

myapplet=parent.appletFrame.document.applets[0];
myapplet.doThisFunction();

But now that I put the applet in an iframe i can no longer get acces to it via the above code. I have to access the iframe differently, as parent.appletFrame.document.applets[0] is not pointing to the applet in the iframe("null or not an object" error is given).

So my question is, "How do you access an applet that is in an iframe so that you can call the applet's functions?"

Thanks in advance!

Jason

AdamBrill
10-06-2003, 12:17 PM
What you have should have worked if you loaded the applet into a page that is inside of the iframe. If the applet is directly in the iframe(no page), then I think you should change this line:

myapplet=parent.appletFrame.document.applets[0];

To this:

myapplet=parent.appletFrame;

See if that works. Also, if the page/applet is getting pulled from a different domain, it probably won't work, since you'll probably get an "access denied" error...

jbergthorson
10-06-2003, 12:53 PM
blah!

Yes it does work... I just had the js file included in the main html file and not in the iframe's html file, so the parent.appletFrame would not exist at that level.

Thanks for making me look over my code adam.