Subject: [JS] The onLoad doesn`t trigger !
Posted By: prem52k Post Date: 1/12/2004 2:49:18 AM
Hi All !
This is my first post here.....!
you see as the title mentions... I have two functions that has to respond as soon as the page loads..Picture a scenario that has the following code.

function siteMsg() {
  window.alert("hello");
}

function pop() {
  window.open('http://www.google.com','newWindow');
}

function all() {
  siteMsg();
  pop();
}

<body onLoad="all()">
bla bla
</body>


if i`m not mistaken this should work perfectly ok...right ?
well it doesn`t, nothing triggers...Does anyone know why, such situations happen ?
thank you.


- Quitters Never Win -
Reply By: joefawcett Reply Date: 1/12/2004 4:48:26 AM
Works fine for me, have you got all code etc. in corect tags?

<html>
<head>
<title>Onload Test</title>
<script type="text/javascript">
  function siteMsg() {
  window.alert("hello");
}

function pop() {
  window.open('http://www.google.com','newWindow');
}

function all() {
  siteMsg();
  pop();
}  
</script>
</head>
<body onLoad="all()">
bla bla
</body>
</html>



--

Joe
Reply By: prem52k Reply Date: 1/12/2004 5:01:29 AM
Hi !
I found the problem. The glitch was in the onLoad itself...
I was not supposed to use more than one onLoad funtion in a script...
(sorry i haven`t mentioned that i`ve posted only a strip-down version of the source above) I found a anothe 'window.onLoad' in the page, got them sorted !
thanx :)

- Quitters Never Win - Winners Never Quit -
Reply By: planoie Reply Date: 1/12/2004 10:18:28 AM
You can put as many things in the onLoad as you want, they just need to be separated by semi-colons at the end of each "line" of JS.

<body onLoad="alert('Hello');alert('World');">
Reply By: prem52k Reply Date: 1/12/2004 8:32:33 PM
yes true !
but you shouldn`t add any other onLoad, any where around the page source !
e.g: window.onLoad.

it will not trigger, the best way to over come this problem is to put all of them in one seprated by semi-colons !

- Quitters Never Win - Winners Never Quit -

Go to topic 8460

Return to index page 971
Return to index page 970
Return to index page 969
Return to index page 968
Return to index page 967
Return to index page 966
Return to index page 965
Return to index page 964
Return to index page 963
Return to index page 962