Click this link for more Java Script Codes

      

Example : How to use/create Script tag in Html?

<!DOCTYPE html>
<html>
	<head>
		<script>
			document.write("Hello You all!");
		</script>	
	</head>
	
	<body>
		<h3>The concept of script tag</h3>
	</body>
</html>

NB: (i) Save the file, say as first.html

-----------------  OR  -----------------

<!DOCTYPE html>
<html>
	<head></head>
	
	<body>
		<h3>The concept of script tag</h3>		
		
		<script>
			document.write("Hello You all!");
		</script>
	</body>
</html>

-----------------  OR  -----------------

<!DOCTYPE html>
<html>
	<head></head>
	
	<body>
		<h3>The concept of script tag</h3>		
		
		<script>
			alert("Hello You all!");
		</script>
	</body>
</html>

-----------------  OR  -----------------

<!DOCTYPE html>
<html>
	<head></head>	
	<body>
		<h3>The concept of script tag</h3>
		<p id="msg"></p>
		
		<script>
		    document.getElementById("msg").innerHTML = "Hello You all!";
		</script>
	</body>
</html>

-----------------  OR  -----------------

<!DOCTYPE html>
<html>
	<head>
		<script>
			function msg()
			{
			 document.write("Hello Developer");			
			}		
		</script>	
	</head>
	
	<body>
		<h3>The concept of Script tag</h3>
		<input type="button" value="Click Me" onclick="msg()"> 
	</body>
</html
Example : How to use/call External Java Script file in Html?
first.html

<!DOCTYPE html>
<html>
	<head>
		<script src="external.js"></script>	
	</head>
	
	<body>
		<h3>The concept of Script tag</h3>
	</body>
</html>

external.js
    document.write("Hello How You all!");

Loading

Categories: HTML

0 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.