Horje

How to add a JavaScript immediately after a page has been loaded

See the code.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
  alert("Page is loaded");
}
</script>
</head>

<body onload="myFunction()">
<h1>Hello World!</h1>
</body>

</html>

Output should be:

How to add a JavaScript immediately after a page has been loaded



Single Articles
How to add a JavaScript immediately after a page has been loadedWindow Event Attributes
How to use onload on an <img> element. Alert "Image is loaded" immediately after an image has been loadedWindow Event Attributes
How to use the onload event to deal with cookies (using "advanced" javascript)Window Event Attributes


Related Articles
What is HTML onafterprint Event Attribute Window Event Attributes
What is HTML onbeforeprint Event Attribute Window Event Attributes
What is HTML onbeforeunload Event Attribute Window Event Attributes
What is HTML onerror Event Attribute Window Event Attributes
What is HTML onhashchange Event Attribute Window Event Attributes
What is HTML onload Event Attribute Window Event Attributes
What is HTML onoffline Event Attribute Window Event Attributes

Type:
Html
Category:
Web Tutorial
Sub Category:
Window Event Attributes
Uploaded by:
Admin