Importing Js file in Html Example

Importing Js file in Html Example

Javadomain.js: [Js file]

function alertMe(){


<script type="text/javascript" src="Javadomain.js" >
<body onload="alertMe();">

What we did:

1. We have written a javascript file named javadomain.js which contains a method called alertMe, which prints Hello

2. Now this method is imported in Import.html file using src attribute of script tag. you can refer the highlighted line above.

3. We have called the alertMe() method from body onload method.

635 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *