JavaScript Introduction

Posted on November 3, 2019 By

JavaScript is a high-level, lightweight, interpreted scripting language used for development of webpage. JavaScript also known as short name “JS”.

JavaScript is a client-side language which means it handle function only on client or users browser, It not interact with server.

JavaScript is used for client-side validation, show popup box or alert window, confirm window, create a menu bar etc.

Example:

<!DOCTYPE html>
<html>
	<head>
		<title>CSS Introduction</title>
		<script>
		function showAlert(){
			alert("Welcome to Javascript Introduction");
		}	

		</script>
         <script src="js/script.js" type="text/javascript"></script>
	</head>
	<body>
		<p>This is Paragraph. Click <a onclick="showAlert();"> here </a> to show alert message.</p>
	</body>
</html>

Output:

This is Paragraph. Click here to show alert message.

Description:

<script>: This tag is used for add javascript function and javascript code. <script> tag can be used between <head> tag or you can also add it in footer of document. You must add javascript function between <script> tags.

Internal Script

Code written between <script> tag in same file where it used is called internal javascript code as shown in above example.

External Script

You can also add external javascript code by including it in file where you want to use. You can see this in above example. Syntax is same as given in above code. Just need to change “src” attribute which is a full path of script file where it located in file directory structure.

To know detail about other tags of HTML document refer here.

Leave a Reply

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