HTML Scripts
Add scripts to HTML pages to make them more interactive and dynamic. |
HTML Scripts |
There are two popular scripts that are commonly used in HTML to make web pages come alive. |
HTML javascript and HTML vbscript |
With HTML scripts you can create dynamic web pages, make image rollovers for really cool menu effects, or even validate your HTML form's data before you let the user submit. |
Insert a Script into HTML Page |
|
A script in HTML is defined with the <script> tag. To specify the scripting language you will have to use the type attribute. | |
|
|
The script above will produce this output: | |
Hello World! |
How to Handle Older Browsers |
|
A browser that does not recognize the <script> tag at all, will display
the <script> tag's content as text on the page. To prevent the browser
from doing this, you should hide the script in comment tags. An old browser
(that does not recognize the <script> tag) will ignore the comment and it
will not write the tag's content on the page, while a new browser will
understand that the script should be executed, even if it is surrounded by
comment tags.
|
|
Example | |
|
The <noscript> Tag
In addition to hiding the script inside a comment, you can also add a <noscript> tag.
|
|
The <noscript> tag is used to define an alternate text if a script is NOT
executed. This tag is used for browsers that recognize the <script> tag,
but do not support the script inside, so these browsers will display the text
inside the <noscript> tag instead. However, if a browser supports the
script inside the <script> tag it will ignore the <noscript> tag.
|
|
|
Script Tags
|