Professional Documents
Culture Documents
Adding JavaScript To HTML Pages
Adding JavaScript To HTML Pages
There are following three ways in which users can add JavaScript to HTML pages.
1. Embedding code
2. Inline code
3. External file
I. Embedding code:-
To add the JavaScript code into the HTML pages, we can use
the <script>.....</script> tag of the HTML that wrap around JavaScript code inside the
HTML program.
<html>
<head>
<meta charset="utf-8">
<title>Including a External JavaScript File</title>
</head>
<body>
<form>
<input type="button" value="Result" onclick="display()"/>
</form>
<script type="text/javascript" src="hello.js">
</script>
</body>
</html>