Re: DOMContentReady and focus() in Opera



On 18/05/09 10:29, Tim Down wrote:
On May 18, 4:05 am, RobG <rg...@xxxxxxxxxxxx> wrote:
Have you considered a belt-and-braces approach? Use both DOM ready
and onload. Have the onload listener check to see if the DOM ready
script has run, if not, set the focus. Do the same with DOM ready,
just in case it calls the listener after onload has run.

That's part of what I'm doing. The window load event is the last resort
if DOMContentReady and polling didn't return a "ready" state sooner.

That has the potential to annoy the user if there is enough time
between the DOM being "ready" and the page finishing loading for the
user to move the focus to a form input other than the first one and
start typing.

Each of the different ways to detect the DOM-is-ready state will cancel
the others, so the handler will only fire once.

Talking about DOMContentReady, that reminds me of something else: is it
was possible to detect whether window/load has already been fired? I was
using a script which did its setup in an onload handler. When this
script was injected at a later point (via <script> element or XHR/eval),
the handler obviously wouldn't be called. I this specific case I could
either "remember" that window/load has already been fired, or call the
included script's setup method directly after including it. Is there any
possibility to handle this if I only have control over the included
script? There's document.readyState, but I don't think that's supported
well enough.


- Conrad
.



Relevant Pages

  • Re: Dynamic select lists using optgroups again - without frameworks
    ... function at the bottom of the last script element, ... in the last script element. ... document.body or whatever) or DOM ready and it has the pleasant side ... Using onload is also based on the "mere assumption" that the UA ...
    (comp.lang.javascript)
  • Re: Causing File Download on Page Load
    ... Script code in the document head or body is executed while the document is ... So script in the onload handler executes after the document is finished loading? ... and not using a wrapper. ...
    (comp.lang.javascript)
  • Re: Dynamic select lists using optgroups again - without frameworks
    ... in the last script element. ... The DOM will be ready and you don't need to use window.onload (or ... Using onload is also based on the "mere assumption" that the UA ... at the time the feature was introduced, ...
    (comp.lang.javascript)
  • Re: Build web apps in Javascript - new service open for beta
    ... You are using the onload event of two entirely different ... was attempting to add an event handler to a single element. ... means do it by script. ... Your "senior programmer" should be demoted to junior ...
    (comp.lang.javascript)
  • Re: Can script determine if window.onload has already fired?
    ... I am also not sure what problem the proposed solution solves. ... OP wanted to delay till onload fired unless onload has fired in which case ... might find your CALLBACK being a tad unreliable, ... script, triggering the browser to load the script. ...
    (comp.lang.javascript)