Website Event Handling (JavaScript)

 JavaScript : It is used for EVENT HANDLING


There are two ways to use it.

1) Write function in HTML file itself. For example
<html>  
<head>  
<script type="text/javascript" src="message.js">
function msg(){  
alert("Hello Javatpoint");  
}  
</script>  
</head>  
<body>  
<p>Welcome to JavaScript</p>  
<form>  
<input type="button" value="click" onclick="msg()"/>  
</form>  
</body>  
</html>  



2) Write JavaScript code in separate file and import it into HTML. For example

aleena.js
----------
function msg(){  
 alert("Hello Javatpoint");  
}  

aleena.html
-----------
<html>  
<head>  
<script type="text/javascript" src="aleena.js"></script>  
</head>  
<body>  
<p>Welcome to JavaScript</p>  
<form>  
<input type="button" value="click" onclick="msg()"/>  
</form>  
</body>  
</html>  

Comments

Popular posts from this blog

C Language

Unix like operating system