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

U

usenet

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.
 
A

ASM

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 ?
 
U

usenet

ASM said:
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' ?


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.
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.
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.
 
A

ASM

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 ?
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
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.

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top