Some Dinosaur
Some Dinosaur

Reputation: 164

How can I create two Onload functions at the same time?

Hi i want to see if it is possible to create two onload functions at the same time.

e.g

<body onload="alert('test')">
<script>
alert("test")
</script>

This does not result 2 alert box's appearing at the same time. Is there a way to cause both to function at the same time resulting multiple alert box's appearing on your screen?

Upvotes: 0

Views: 1149

Answers (1)

emregulcan
emregulcan

Reputation: 88

you can define a function and you can call other functions inside this. for example;

function pageOnload()
{
   myAlert();
   sayHello("emre");
}

function myAlert()
{
  alert("my alert runs");
}

function sayHello(name)
{
   alert("hi " + name);
}

and after you can call "pageOnload()" method on your html

<body onload="pageOnload()">

Upvotes: 1

Related Questions