right javascript syntax

K

korund

What is correct syntax for the following scenario: show five alerts,
one by one(text different), when page loads in browser -on body onload:

alert(text 1)
alert(text 2)
alert(text 3)
alert(text 4)
alert(text 5),

then code

var iCounter=0;while(true)window.open('http://www.google.com')}};"...

how it need be in html page?
 
K

korund

so I asked for correct syntax - there should be 2 google window, not a
billion, however.
 
K

korund

Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init();"> ? What from
methods will call code faster?
The page will contain image, that need be loaded.
 
O

[on]

so I asked for correct syntax - there should be 2 google window, not a
billion, however.

The Reason I asked is cause, if you intented to open a billion windows
(like the code suggested), you would not have been helped. Atleast not
by me.
 
O

[on]

Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init();"> ? What from
methods will call code faster?
The page will contain image, that need be loaded.

Shouldn't be any difference, both basically tells the client to run the
function when the page is finnished loaded (all imageas and whatnot).

It all depends on where you want the code, that runs the function, to
be.
 
K

korund

Hmm,

<body onload="init();"> - this will tell client run script when the
page is finished loaded, but window.onload = init; inside <head> will
cause run script immediately?
 
D

David Dorward

<body onload="init();"> - this will tell client run script when the
page is finished loaded, but window.onload = init; inside <head> will
cause run script immediately?

No. The post to which your message headers claim you are responding, but
which you entirely fail to quote ...

http://cfaj.freeshell.org/google/

.... is quite clear that they have the same effect as far as timing is
concerned.
 
T

Thomas 'PointedEars' Lahn

Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init();"> ?

No. Both are subject to popup blockers.
What from methods will call code faster?

The code will be executed at the same
speed, at approximately the same time.
The page will contain image, that need be loaded.

The UA will load them already.


PointedEars
 
V

VK

Thanks. Is there any difference to fire code via window.onload = init;
located inside <head> tags, or via <body onload="init();"> ?

As parenthesis suggest in the latter variant, you can send arguments to
your function.
In the reality it is an anonymous function calling init() function.
Internally it is:
<body onload="function anonymous(event){ init(); }">
So if you need to supply arguments in the conventional way, intrinsic
handler like <body onload="init();"> is more convenient.

There are also suggestions, which I didn't check through for all
browsers, that intrinsic handler has priority over in-code handlers,
thus between
....
window.onload = doThis;
....
<body onload="doThat();">
....
doThat will be called first no matter what. As I said I did not verify
this.

Otherwise it is probably better to keep JavaScript code by itself and
HTML markup by itself.

There is no productivity impact in neither case.
 
T

Thomas 'PointedEars' Lahn

Thomas said:
No. Both are subject to popup blockers.

Actually, there is a difference. The first is proprietary,
the second is not. But that does not matter here :)


PointedEars
 
K

korund

Amplifications: it seems, javascript alerts have more high priority
than popup pages(windows), since first is usually shown without
problems, but second are blocked by built-in MSIE popup blocker.
 
D

David Dorward

Amplifications: it seems, javascript alerts have more high priority
than popup pages(windows), since first is usually shown without
problems, but second are blocked by built-in MSIE popup blocker.

Popup adverts are common and annoying.

Alertbox adverts are rare (and not that useful to advertisers as they can't
have pretty graphics or links in them).

It is adverts that users typically want to block, so browsers deliver
features to try to meet that want.
 
T

Thomas 'PointedEars' Lahn

Amplifications: it seems, javascript alerts have more high priority
than popup pages(windows), since first is usually shown without
problems, but second are blocked by built-in MSIE popup blocker.

IE is not the only browser around, nor is IE6 SP2's popup blocker the
only popup blocker around.


PointedEars
 
K

korund

Thomas said:
IE is not the only browser around, nor is IE6 SP2's popup blocker the
only popup blocker around.


PointedEars

Not clear. I need all my javascript alerts MUST be shown for user. MSIE
popup blocker or other wind services should not disable it.
 
T

Thomas 'PointedEars' Lahn

Thomas 'PointedEars' Lahn wrote:
(e-mail address removed) wrote:
Thanks. Is there any difference to fire code via window.onload =
init; located inside <head> tags, or via <body onload="init();"> ?
No. Both are subject to popup blockers.
Amplifications: it seems, javascript alerts have more high priority
than popup pages(windows), since first is usually shown without
problems, but second are blocked by built-in MSIE popup blocker.
IE is not the only browser around, nor is IE6 SP2's popup blocker the
only popup blocker around.
[...]

Not clear. I need all my javascript alerts MUST be shown for user.
MSIE popup blocker or other wind services should not disable it.

Therefore, you should not use alert() messages in event listeners for the
`load' event. And what about users without client-side script support?


PointedEars
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top