Firefox and <body onload=.. > firing after page is rendered

Discussion in 'Javascript' started by usenet@ctoxyeb.com, Aug 16, 2005.

  1. Guest

    Hi All,

    I have some initialization to be done at page load time, which changes
    the text of some anchors so that they are consistent with the query
    string (these anchors are used as criteria selectors, and should be
    initialized to the criteria contained within the url).

    IE and Safari fire the onload event before rendering any elements, so
    when the event handler synchronizes the anchors, they are rendered with
    the right contents immediately. Firefox, though, renders the page
    first, and then fires the handler, which results in the anchors getting
    their initial values, and then changing to proper selections. I've
    tried calling my init() method immediately after the anchors are
    defined in my document - no difference, looks like Firefox is rendering
    everything as soon as it's encountered in the document.

    Is there any way to have my code run before any elements are rendered
    in Firefox? Currently I've "solved" this by hiding the containing div
    in the document, and showing it after making changes. This results in
    the UI visually reloading itself with each new page, which is not very
    desirable either.
     
    , Aug 16, 2005
    #1
    1. Advertising

  2. ASM Guest

    wrote:
    > Hi All,
    >
    > I have some initialization to be done at page load time, which changes
    > the text of some anchors so that they are consistent with the query
    > string (these anchors are used as criteria selectors, and should be
    > initialized to the criteria contained within the url).


    once more I do understand anything

    What is the text of an anchor ? (no sense for me)
    What do you call an 'anchor' ? is it a 'tag' ?

    > looks like Firefox is rendering
    > everything as soon as it's encountered in the document.


    usually it's the way of doing with IE (Mac ?)

    > Is there any way to have my code run before any elements are rendered
    > in Firefox?


    what kind of code do you use to re-render your anchors ?
    (don't more know what you mean)

    > Currently I've "solved" this by hiding the containing div
    > in the document, and showing it after making changes. This results in
    > the UI visually reloading itself with each new page, which is not very
    > desirable either.


    why don't you send the right code insteed to re-write it on the fly ?


    --
    Stephane Moriaux et son [moins] vieux Mac
     
    ASM, Aug 16, 2005
    #2
    1. Advertising

  3. Guest

    ASM wrote:
    > wrote:
    > > Hi All,
    > >
    > > I have some initialization to be done at page load time, which changes
    > > the text of some anchors so that they are consistent with the query
    > > string (these anchors are used as criteria selectors, and should be
    > > initialized to the criteria contained within the url).

    >
    > once more I do understand anything
    >
    > What is the text of an anchor ? (no sense for me)
    > What do you call an 'anchor' ? is it a 'tag' ?


    It's a regular <a> tag, when clicked it opens a selector box, and once
    a selection is made, the link text is changed to the selected item.

    > > looks like Firefox is rendering
    > > everything as soon as it's encountered in the document.

    >
    > usually it's the way of doing with IE (Mac ?)


    I've actually checked, IE delays rendering the page until everything is
    parsed and onload() is called before rendering.

    >
    > > Is there any way to have my code run before any elements are rendered
    > > in Firefox?

    >
    > what kind of code do you use to re-render your anchors ?
    > (don't more know what you mean)


    Standard stuff like:

    var div = getElementById('divId');
    div.innerHTML = newText;

    Html for this is along hte lines of:

    <a href="#" onclick="openSelector(); return false">
    <div id=divId>Selection</div></a>

    Once a selection is made, "Selection" gets replaced with the actual
    item.

    None of this actually matters, though - the problem is that at the time
    of unload() the page is already rendered. This is easily seen using
    <body onload='alert("onload");'> - in FF, the dialog box is displayed
    with the page contents rendered, while in IE/Safari it's displayed over
    an empty page, and it's rendered after you click OK.

    >
    > > Currently I've "solved" this by hiding the containing div
    > > in the document, and showing it after making changes. This results in
    > > the UI visually reloading itself with each new page, which is not very
    > > desirable either.

    >
    > why don't you send the right code insteed to re-write it on the fly ?


    Because this is all done client-side, and I'd like to keep it that way
    to avoid unnecessary server load.
     
    , Aug 16, 2005
    #3
  4. ASM Guest

    wrote:
    > ASM wrote:
    >
    >> wrote:
    >>
    >>>Hi All,
    >>>
    >>>I have some initialization to be done at page load time, which changes
    >>>the text of some anchors so that they are consistent with the query
    >>>string (these anchors are used as criteria selectors, and should be
    >>>initialized to the criteria contained within the url).

    >>
    >>once more I do understand anything


    re-reading (with lighting bellow)
    I understand you want to change content of divs (or links)
    with what follow an url ( foo.htm?criter1=New text&criter2=Other text )

    Couldn't you have a script in header's top
    to stock this criterias in global variables

    then along lines with links to modify
    have JS script(s) to write the correct text(s) comming from this variables ?

    >>What is the text of an anchor ? (no sense for me)

    >
    > It's a regular <a> tag,


    well, we talk about same thing
    but, in fact, probably you speak about links

    > when clicked it opens a selector box,


    I don't know what it is in JavaScript

    > and once
    > a selection is made, the link text is changed to the selected item.


    let's say so

    >>what kind of code do you use to re-render your anchors ?

    >
    > Standard stuff like:
    >
    > var div = getElementById('divId');
    > div.innerHTML = newText;
    >
    > Html for this is along hte lines of:
    >
    > <a href="#" onclick="openSelector(); return false">
    > <div id=divId>Selection</div></a>


    <a id="divId" href="#" onclick="openSelector(); return false">
    Selection</a>

    or, if possible (global variable in header)

    <a href="#" onclick="openSelector(); return false">
    <script type="text/javascript">document.write(criter_1)</script></a>

    because I've seen openSelector() is a Java function
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=openSelector()

    Are you using Java ?
    If yes, I can do anything for you, sorry.

    > Once a selection is made, "Selection" gets replaced with the actual
    > item.


    Not too hard to do (I think) even if I don't understand what it wiil
    do with the NewSelectionText on next click on this link ...

    > None of this actually matters, though - the problem is that at the time
    > of unload()


    *on*load I presume

    > the page is already rendered. This is easily seen using
    > <body onload='alert("onload");'> - in FF, the dialog box is displayed
    > with the page contents rendered, while in IE/Safari it's displayed over
    > an empty page, and it's rendered after you click OK.


    I see.

    >>>Currently I've "solved" this by hiding the containing div
    >>>in the document, and showing it after making changes.


    If you can't start the job before end of load
    I do not see how to do other way



    --
    Stephane Moriaux et son [moins] vieux Mac
     
    ASM, Aug 16, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    4
    Views:
    1,644
    Jason
    May 7, 2007
  2. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    585
    Martin Honnen
    Nov 4, 2004
  3. Replies:
    0
    Views:
    184
  4. stevong
    Replies:
    3
    Views:
    445
    Randy Webb
    Jan 20, 2006
  5. yawnmoth
    Replies:
    7
    Views:
    156
Loading...

Share This Page