The HTML Tag Is Used To Insert A Vbscript Into An HTML Page
The HTML Tag Is Used To Insert A Vbscript Into An HTML Page
The HTML Tag Is Used To Insert A Vbscript Into An HTML Page
What is VBScript?
VBScript is a scripting language
A scripting language is a lightweight programming language
VBScript is a light version of Microsoft's programming language Visual Basic
How Does it Work?
When a VBScript is inserted into an HTML document, the Internet browser will read the HTML and
interpret the VBScript. The VBScript can be executed immediately, or at a later event.
The HTML <script> tag is used to insert a VBScript into an HTML page.
Put a VBScript into an HTML Page
The example below shows how to use VBSript to write text on a web page:
<html>
<body>
<script type="text/vbscript">
document.write("<h1>Hello World!</h1>")
</script>
</body>
</html>
Example Explained
To insert a VBScript into an HTML page, we use the <script> tag. Inside the <script> tag we use the
type attribute to define the scripting language.
So, the <script type="text/vbscript"> and </script> tells where the VBScript starts and ends:
The document.write command is a standard VBScript command for writing output to a page.
By entering the document.write command between the <script> and </script> tags, the browser will
recognize it as a VBScript command and execute the code line. In this case the browser will write
Hello World! to the page:
<html>
<body>
<script type="text/vbscript">
...
</script>
</body>
</html>
<html>
<body>
<script type="text/vbscript">
document.write("Hello World!")
</script>
</body>
</html>
VBScripts can be placed in the body and in the head section of an HTML document.
Scripts in <head>
Put your functions and sub procedures in the head section, this way they are all in one place, and they
do not interfere with page content.
Scripts in <body>
If you don't want your script to be placed inside a function, and especially if your script should write
page content, it should be placed in the body section.