By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,796 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,796 IT Pros & Developers. It's quick & easy.

problem reading DOM after window.open with url

P: n/a
I'm having a curious problem. I open a window with window.open method
and supply a url which is a local file of file:/// form. After that, I
go into the document of this new window to read the DOM for multiple
forms which are defined in the html. The problem is that the objects are
not immediately there. To make them available, I've found that if I do a
View, Source from the new window's menu bar, THEN the DOM forms are
there as expected.

I'm using Mozilla 1.7.3; maybe it's my browser version. Problem with
using Firefox for me, the access to local content is limited. I tried
the change to the configuration that is supposed to allow this, but it
didn't work.
Dec 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

John Derry wrote:
I'm having a curious problem. I open a window with window.open method
and supply a url which is a local file of file:/// form. After that, I
go into the document of this new window to read the DOM for multiple
forms which are defined in the html. The problem is that the objects are
not immediately there. To make them available, I've found that if I do a
View, Source from the new window's menu bar, THEN the DOM forms are
there as expected.
You may be trying to read the document before it's finished loading.
Some suggestions:

1. Have the new document set a variable onload. Use setTimeout to
check for the variable every 200ms or so until it's available, then do
stuff. Set a limit on the number of re-tries.

2. Have a function in the new page run onload to call the function in
the parent page that does stuff.

3. Guess at how long it will take to load the new page and use
setTimeout to wait that long before starting to process it. Check that
elements exist before trying to do anything with them.

Option 1 is OK, 2 is reasonably elegant, 3. is pretty awful.
--
Rob

Dec 19 '06 #2

P: n/a
RobG wrote:
John Derry wrote:
>>I'm having a curious problem. I open a window with window.open method
and supply a url which is a local file of file:/// form. After that, I
go into the document of this new window to read the DOM for multiple
forms which are defined in the html. The problem is that the objects are
not immediately there. To make them available, I've found that if I do a
View, Source from the new window's menu bar, THEN the DOM forms are
there as expected.


You may be trying to read the document before it's finished loading.
Some suggestions:

1. Have the new document set a variable onload. Use setTimeout to
check for the variable every 200ms or so until it's available, then do
stuff. Set a limit on the number of re-tries.

2. Have a function in the new page run onload to call the function in
the parent page that does stuff.

3. Guess at how long it will take to load the new page and use
setTimeout to wait that long before starting to process it. Check that
elements exist before trying to do anything with them.

Option 1 is OK, 2 is reasonably elegant, 3. is pretty awful.

You are absolutely right. While I'm waiting for the browser to get the
window open, my script has plowed ahead. I can loop until I see the flag
that I set, in onLoad event handler associated with the window, but
that is too long and the browser complains my script is taking too long.

Thanks alot for the help,
John
Dec 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.