Such a command as 'onbeforeload'?

C

CJS

Hi, I have a javascript popup which I want to happen BEFORE the rest of the
page loads. It's something for people to read while quite a heavy page
loads behind it.

I tried using 'onbeforeload' instead of 'onload' in the Body tag, but it
doesn't pop up at all then.

Any ideas?

Thanks.
 
N

nolo contendere

Hi, I have a javascript popup which I want to happen BEFORE the rest of the
page loads. It's something for people to read while quite a heavy page
loads behind it.

I tried using 'onbeforeload' instead of 'onload' in the Body tag, but it
doesn't pop up at all then.

I didn't see such an event. But what are you trying to accomplish?
Perhaps there is a way to do what you require via another path.
 
T

Thomas 'PointedEars' Lahn

CJS said:
Hi, I have a javascript popup which I want to happen BEFORE the rest of the
page loads. It's something for people to read while quite a heavy page
loads behind it.

If it is a popup window, it will be blocked. If it is something else,
loading it will only slow down or prevent loading of the other, more
important content; if it even works.

In any case, it is nothing that can be recommended. BTDT. You are far
better off with either reducing the size of the "heavy page", for example by
splitting it into several documents, and/or with structuring it better (for
example by avoiding layout tables in favor of CSS-positioned blocks) so that
the user can read the main content while it is loading.


F'up2 comp.lang.javascript

PointedEars
 
N

nolo contendere

Hi, I have a javascript popup which I want to happen BEFORE the rest of the
page loads. It's something for people to read while quite a heavy page
loads behind it.

I tried using 'onbeforeload' instead of 'onload' in the Body tag, but it
doesn't pop up at all then.

Any ideas?

You could start off by showing a loader of some sort (image, txt,
whatever) in a div (style="display: block;"), with your content in a
div (style="display: none;"), and onload, call a function that sets
the loader div to display: none and the content div to display: block.
 
C

CJS

nolo contendere said:
I didn't see such an event. But what are you trying to accomplish?
Perhaps there is a way to do what you require via another path.

Simply what I want to accomplish is the popup to come up *first* befoer any
other page elements load. It is complicated as to why, and other factors,
but that is what needs to happen.

The onload tag seems to open happen after the page has finished loading
completely, which is odd.
 
R

Randy Webb

CJS said the following on 11/15/2007 4:44 AM:

[follow-up set to comp.lang.javascript]
Simply what I want to accomplish is the popup to come up *first* befoer any
other page elements load. It is complicated as to why, and other factors,
but that is what needs to happen.

The onload tag seems to open happen after the page has finished loading
completely, which is odd.

Want something to happen during load? Don't use onload. It fires after
the element has completely loaded. Why you would find it odd that an
event that is defined to trigger after the element is completely loaded
only fires after the element is completely loaded is, well, odd to say
the least.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
N

nolo contendere

Simply what I want to accomplish is the popup to come up *first* befoer any
other page elements load. It is complicated as to why, and other factors,
but that is what needs to happen.

The onload tag seems to open happen after the page has finished loading
completely, which is odd.

Hmm, a friend of mine uses the technique I mentioned and it works
fine. Have you tried the <div> swapping thing? It is precisely
*because* the onload happens *after* the page has loaded that you can
use that as the event to trigger the <div> display swap.

And while the page is in the process of loading, the onload event has
not fired yet, but the loader div is being displayed. I realize that
this doesn't give you the popup you requested, but it serves as a
solution to your ultimate goal of providing the user with feedback
that a heavy page is loading.

HTH
 
N

nolo contendere

Simply what I want to accomplish is the popup to come up *first* befoer any
other page elements load. It is complicated as to why, and other factors,
but that is what needs to happen.

The onload tag seems to open happen after the page has finished loading
completely, which is odd.

Try something like this:

<html>
<head>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript">
function kill_loader() {
$('loader').style.display = 'none';
$('contents').style.display = 'block';
}
</script>
</head>
<body onload="kill_loader();">
<div id=loader style="display: block; overflow: auto; valign: middle;
text-align: center; background-color: #fff; width: 100%; height:
100%;">
<img src="images/spinner.gif" />
</div>
<div id=contents style="display: none;">hi there</div>
</body>
</html>
 
G

Gregor Kofler

nolo contendere meinte:
<html>
<head>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript">
function kill_loader() {
$('loader').style.display = 'none';
$('contents').style.display = 'block';
}

Prototype just to get rid off document.getElementById()? I suppose it 'd
more helpful for the OP, if he could get the plain JS version, hence

document.getElementById('loader').style.display = 'none';
document.getElementById('contents').style.display = 'block';


Gregor
 
N

nolo contendere

nolo contendere meinte:


Prototype just to get rid off document.getElementById()? I suppose it 'd
more helpful for the OP, if he could get the plain JS version, hence

document.getElementById('loader').style.display = 'none';
document.getElementById('contents').style.display = 'block';


heh, thanks.
 
J

Jonathan N. Little

nolo said:
Try something like this:
<snip code>

If the initial page takes so long to load that you need an progress
indicator, then maybe you need to reevaluate the content of your page
and break it up into more manageable size bits...
 
A

André Gillibert

CJS wrote:

Simply what I want to accomplish is the popup to come up *first* befoer
any other page elements load. It is complicated as to why, and other
factors, but that is what needs to happen.

Something very simple that works in most browsers:
Put a script at the top of your document, in the HEAD.
It will typically be executed as soon as the browser parses it, and before
the document is entirely loaded.
The onload tag seems to open happen after the page has finished loading
completely, which is odd.

No, it isn't odd. The onload function is EXACTLY for that. It ensures that
the DOM is complete.
 
A

André Gillibert

nolo contendere wrote:

And while the page is in the process of loading, the onload event has
not fired yet, but the loader div is being displayed. I realize that
this doesn't give you the popup you requested, but it serves as a
solution to your ultimate goal of providing the user with feedback
that a heavy page is loading.

No, it's rather REMOVING feedback during page loading.

The only thing that the user knows is: Something is loading or frozen due
to a buggy JavaScript (very common) or JavaScript disabled or a connection
problem (e.g. an element of the page for which the connection has been
closed by the server but the user agent didn't notice that).

With progressive rendering, you see exactly what's loading as it's
displayed.

I also noticed that some sites containing this awful hack, the loading of
the entire page becomes much slower (e.g. 14 or 15 seconds instead of 2 or
3) because all the tiny useless icons advertisements and 1x1 images (e.g.
to do some cr*ppy statistics) at the bottom of a site require much time to
be loaded.

If you hate progressive rendering, please, don't harm MY computer, simply
disable progressive rendering in YOUR browser.
e.g. with Opera go to Tools->Preferences->Advanced->Browsing->Loading and
check "Redraw when loaded".

As a general solution, write a little HTTP proxy application that disable
progressive rendering. But, please, use it for personal use.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top