HTML Script

HTML Script

HTML allows programmers to include scripts in HTML Page. JavaScript which is a client side scripting language can be included in  HTML Page. HTML provides <script>  tag to include  java script  inside  HTML Page. <script> Element can contain direct  scripting code or we can point to an external script file using src attribute. Java script  are used to make html pages dynamic. It can be used for image manipulation and form validation. Html provides flexibility to include java script code. We can include java script code in   <head> section  and  <body> section. 

<html>
<head>
<title>Scripting</title>
</head>
<body>
<script>
document.write("Hello Scripting"); </script>
</body>
</html>

Output

Scripting
Or we can write code in an external file and include the source name in the <head> section of html page.
<html>
<head>
<title>External Scripting</title>
<script type="text/javascript" src="exeternal.js"></script>
</head>
<body>
</body>
</html>

external.js

var v=10+30;
document.write("The sum is "+v);

Output


The sum is 40
HTML <noscript> tag 

Sometimes script may be disabled in user browsers or the browser may not support scripts. To handle such cases html provides <noscript> tag to provide an alternative content for users. <noscript> Element can contain all elements that are supported by html. The contents inside <noscript> tag will be displayed only if the browser dose not support scripting or script is disabled in the browser.
<html>
<head>
<title>No Script tag</title>
</head>
<body>
<script>
document.write("Hello Scripting");
</script>
<noscript>Sorry man your browser doesnot support java script</noscript>
<p>A browser that does not support JavaScript will show the text written inside the noscript element.</p>
</body>
</html>

Output

No Script tag

A browser that does not support JavaScript will show the text written inside the noscript element.

0 Comment "HTML Script"