Click to See Complete Forum and Search --> : Acessing new window frames


curen
06-05-2003, 10:45 AM
Hi,

I open a new window with the following code:

newwin = window.open('NewWindow.htm', 'newwin','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=670,height=450,l eft = 100,top = 50');
setTimeout("newwin.focus();",500);
setTimeout("newwin.opener=self",500);
setTimeout("newwin.main.location= 'Example.htm",1000);
setTimeout("newwin.footer.location = 'Example2.htm'",1000);

I have used setTimeout everywhere to allow for the time it takes for the window to open.

However I still have problems sometimes on the following line:
setTimeout("newwin.main.location= 'Example.htm",1000);

where it is saying newmain.main is null or not an object.

What I am assumming is happening is that the window has been opened but the frameset has not had sufficient time to load.

Hence I need to be sure the frameset exists before trying to load a page into it.

However, I cannot just use a loop checking the value because this will use precious CPU time and slow the loading of the frameset even more. I also cannot just keep increasing the setTimeout value as I can never be sure it will work in all situations.

Does anyone have any other suggestions about how to get round this.

Thanks

Chris

Khalid Ali
06-05-2003, 11:31 AM
Hello Chris,
Use the <frameset onload="..."

onload event call for this purpose,that way it will use the settimeout function only after the frames are loaded..

curen
06-06-2003, 02:49 AM
Thanks for your reply.

However I am slightly confused.

I understand the theory behind your example and it seems like an excellent idea.

However, surely I would catch the onload event in the new page. But the new window doesn't know what page to load into the frameset because it can change dependent upon which page calls it.

Therefore trapping onload in the new page will not help as I don't know what page to load.

Or from the original page can I set up the onload parameter for the new window?

Thanks once again

Chris
---------------------------------------
www.bathweather.co.uk

Khalid Ali
06-06-2003, 08:50 AM
yes you should be able to do that....I might not have understood your problem correctly...however...take a look at this page...it makes sure that both frames have been loaded in a frameset and then prints a string on each frame.
On top of that it gives a great deal of information on how to interact with frames....in a frameset.

http://68.145.35.86/skills/javascripts/frames/FramesConfirmSubFramesAreLoaded.html

Interesting bit..if you can elaborate on the specs of your bproblem a bit more,I am willing to work on it with you.

curen
06-06-2003, 10:14 AM
Thanks again for your reply.

Looking at that website has solved all my problems.
I tried to do something similar before but in the if statements I tested the frame directly without first assigning it to a variable.

Thanks

Chris
--------------------------------
www.bathweather.co.uk

Khalid Ali
06-06-2003, 10:15 AM
My pleasure..:p