Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Firefox and <body onload=.. > firing after page is rendered

Reply
Thread Tools

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

 
 
usenet@ctoxyeb.com
Guest
Posts: n/a
 
      08-16-2005
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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      08-16-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
usenet@ctoxyeb.com
Guest
Posts: n/a
 
      08-16-2005

ASM wrote:
> (E-Mail Removed) 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.

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-16-2005
(E-Mail Removed) wrote:
> ASM wrote:
>
>>(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
executing a server method after page is rendered jphaycock@googlemail.com ASP .Net 10 08-29-2007 09:58 AM
background thread after page is being rendered NIan ASP .Net 2 09-15-2005 03:44 PM
half rendered page on first load :-( after refreshing everything is fine Daniel Walzenbach ASP .Net 7 02-10-2004 09:02 AM
Newbie - Rendered controls not firing events - help please Paul ASP .Net Building Controls 0 12-12-2003 12:22 PM
running scrip after the page is rendered. Ed Javascript 1 07-18-2003 02:39 PM



Advertisments