Categories
computer programs

how can you Add scripts to HTML

Spread the love
0
(0)

HTML scripts
Add scripts to HTML pages, to make them more dynamic and interactive.
Inserting script into HTML pages
Script is added to HTML files by tag <script>, and it should be noted that the “type attribute” should be used to indicate the script language.
As shown in the following example:
<html>
<head>
</head>
<body>
<script type = “text / javascript”>
document.write (“hello guys this is blindmasters”)
</script>
</body>
</html>
The previous example will produce the following outputs:
hello guys this is blindmasters
How to Handle Older Browsers
The browser, which cannot recognize the script tag, will display the contents of the script tag as text inside the page.
To prevent the browser from doing so, we must hide the script inside the comment tag “Notes”.
Older browsers “that do not recognize the script tag” will ignore the comment and therefore the script text will not be displayed within the contents of the page.
Whereas, new browsers will understand that the script must be executed even if it is placed inside the comment tag.
Example:
JavaScript:
<script type = “text / javascript”>
<! –
document.write (“Hello World!”)
// ->
</script>
VBScript:
<script type = “text / vbscript”>
<! –
document.write (“Hello World!”)
‘->
</script>
<noscript> tag
In addition to hiding the script inside the comment tag, a <noscript> tag can be added.
A <noscript> tag is used to specify alternative text that is displayed when the script is not executed.
This tag is used for browsers that recognize scripts but do not support scripts inside the page. Therefore, these browsers will display the text inside the <noscript> tag instead of executing the script.
However, if the browser supports the script inside the page, then the script tag will ignore the <noscript> tag.
Example:
JavaScript:
<script type = “text / javascript”>
<! –
document.write (“Hello World!”)
// ->
</script>
<noscript> Your browser does not support JavaScript! </noscript>
VBScript:
<script type = “text / vbscript”>
<! –
document.write (“Hello World!”)
‘->
</script>
<noscript> Your browser does not support VBScript! </noscript>
Thanks for referring to our article on how can you Add scripts to HTML

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

 
Live Chat

Hi, Your satisfaction is our top priority, we are ready to answer your questions...