|
Loading...
|
dev-extensions@lists.mozilla.org
[Prev] Thread [Next] | [Prev] Date [Next]
Re: help! problems after window.open() bootstrap Mon Apr 02 16:01:58 2012
On Apr 2, 2:09 pm, Benjamin Smedberg <[EMAIL PROTECTED]> wrote:
> On 4/1/2012 10:52 PM, bootstrap wrote:> In
>> Now, back in the function that calls win = window.open(), there is a
>> tiny bit of sense, but not much. After that win = window.open()
>> function call, win.name does contain the name of the window supplied
>> in the second argument of window.open(). A miracle! However...
>
>> win.document.getElementsByTagName("html").length // returns 1 ==
>> correct
>> win.document.getElementsByTagName("body").length // returns 1 ==
>> correct
>> win.document.getElementsByTagName("font").length // returns 0 ==
>> WRONG --- should be 1
>
> At what point are you making these calls? Note that immediately after
> you create the window using window.open, it only has about:blank loaded
> into it. The URL you specified has not yet loaded into it. So AFAICT the
> answers you are getting are correct. You can probably add a load
> listener to the window and then when you do receive a load notification,
> win.document will have your new page loaded into it.
>
> --BDS
PS: I didn't see my message appear for over a day, so I posted
a new message just a while ago (with somewhat more details).
But let me answer your specific questions below.
To test my code, I create event listeners for "window.load" and
"mousedown" events.
Inside my "mousedown" event handler function I capture the
screenX, screenY of the mouse cursor from the event structure,
then create a path string, a feature string, then call
win = window.open(pathstring, "clarify", featurestring);
Note that the pathstring refers to an HTML file on my ubuntu64
linux filesystem, so it is something like the following:
"file://home/max/firefox/extension/meanings/content/clarify.html"
Now, I have dozens of print statements in these TWO places:
#1: inside my "window load" event handler function.
#2: inside my "mousedown" event listener function.
#2 is immediately following my window.open() call.
Inside #1, I take the event argument and work through
every conceivable element to attempt to find a window
with name == "clarify" (as set by window.open()).
I am unable to find such a window, and the windows
I do find have no name, and no <p> tags or id = "clarify".
The print statements at #2 are a bit simpler, because
I have the win variable, which is supposed to be the
reference to the window created by window.open()
according to the window.open() documentation.
But I go through every possible permutation trying
to find another window that has a <p> tag or has
an id = "clarify" (which is in the loaded HTML file).
Also note this. As we would expect, since javascript
is essentially a single-thread model, my printouts
confirm that BEFORE my window.open() call returns,
my installed "window load" event handler function is
called by javascript. Therefore, the window is already
fully loaded before my printouts mentioned in #2 above.
And, in fact, the window should be fully loaded before
my printouts mentioned in #1 above too.
Therefore, you assumption is wrong. The HTML file
is fully loaded when the lines following window.open()
are executed. At least that is DEFINITELY how this
works on my ubuntu64 system works (firefox v11), as
demonstrated by the order of my printout statements.
The bottom line is, I am already doing what you
suggest IN ADDITION TO the same tests after
the window.open() function call. So that doesn't
explain what my problem is.
Any other ideas?
_______________________________________________
dev-extensions mailing list
[EMAIL PROTECTED]
https://lists.mozilla.org/listinfo/dev-extensions
- help! problems after window.open() bootstrap 2012/04/02
- Re: help! problems after window.open() Benjamin Smedberg 2012/04/02
- Message not available
- Re: help! problems after window.open() bootstrap 2012/04/02 <=
- Re: help! problems after window.open() bootstrap 2012/04/02
- Re: help! problems after window.open() Dave Townsend 2012/04/02
- Re: help! problems after window.open() bootstrap 2012/04/04
- Re: help! problems after window.open() Neil 2012/04/03
- Re: help! problems after window.open() bootstrap 2012/04/03
- Re: help! problems after window.open() Neil 2012/04/04
- Re: help! problems after window.open() bootstrap 2012/04/04
- Re: help! problems after window.open() bootstrap 2012/04/04