Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes HTML, CSS and JavaScript and the fly likes Before pageload event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Before pageload event" Watch "Before pageload event" New topic

Before pageload event

Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
I am trying to hook into the event that is triggered before the page starts loading. Is this possible. Window.onload is executed after the page is loaded, so it is too late for what I am trying to do.
The sequence of events as I understand it
1) The bowser sends a request
2) The browser receives a reponse
3) The browser starts loading the page
4) The page is loaded
5) The browser executes onload event if it is connected

I am trying to hook into step 3 if possible. I have searched quite a bit and have not found much. Thanks for your help.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Well adding a script tag to the page is called as the page is rendering.

What are you trying to accomplish exactly?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

At what point are you trying to hook into? Before or after the DOM is constructed?

[Asking smart questions] [About Bear] [Books by Bear]
Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
I am troubleshooting an issue where our application hangs for about 20 minutes sporadically. Here is a partial html response which I got by doing view source.

I see line 1 printed in the log after 20 minutes of browser sending the request. Using app server logs and network logs, it is confirmed that the response does make it back to the workstation and the time taken is less than a minute. Our app runs in an embedded environment. I am trying to see if the first lines until the first script tag is taking those 20 minutes. I know it is unlikely, but I would like to prove it to myself that it is not the cause of the issue. My question is
1) When the browser(IE) sees the first lines until the first script tag, what does it do, does it try and access these sites and download the dtd, and

One possibility might be that the user has difficulty accessing these sites and so the browser just waits there.
Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
Before DOM is constructed.
I agree. Here's the link:
subject: Before pageload event
It's not a secret anymore!