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

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

P: n/a
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 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ASM
us****@ctoxyeb.com 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
Aug 16 '05 #2

P: n/a

ASM wrote:
us****@ctoxyeb.com 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 '05 #3

P: n/a
ASM
us****@ctoxyeb.com wrote:
ASM wrote:
us****@ctoxyeb.com 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/ones...Selector%28%29

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
Aug 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.