Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to execute the script when the page has finished parsing in HTML?
Use the defer attribute to execute the script when the page has finished parsing in HTML.
Firstly, add a js file.
Let us give it a name, new.js,
function sayHello() {
alert("Hello World")
}
Example
Let’s add the HTML code now and execute the above script −
<html> <head> <script src = "new.js" defer></script> </head> <body> <p>This is demo text.</p> </body> </html>
Advertisements
