Horje

How to add a JavaScript when a user navigates to a webpage

See the code.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body onpageshow="myFunction()">

<h1>Hello World!</h1>

<script>
function myFunction() {
  alert("Welcome!");
}
</script>

</body>
</html>

Output should be:

How to add a JavaScript when a user navigates to a webpage



Single Articles
Example of HTML onpageshow Event AttributeWindow Event Attributes
Browser Support of HTML onpageshow Event AttributeWindow Event Attributes
Syntax of HTML onpageshow Event AttributeWindow Event Attributes
Attribute Values of HTML onpageshow Event AttributeWindow Event Attributes
Technical Details of HTML onpageshow Event AttributeWindow Event Attributes
How to add a JavaScript when a user navigates to a webpageWindow 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
What is HTML ononline Event Attribute Window Event Attributes
What is HTML onpageshow Event Attribute Window Event Attributes
What is HTML onresize Event Attribute Window Event Attributes

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