The Basics of Javascript and VBScript


Javascript (JS) was introduced a while back (sometime around the mid '90s) to make HTML
dynamic. Originaly, it was only supported by Netscape, but after a while, Microsoft
introduced a scaled-back version called JScript. Eventually, Microsoft introduced its own
scripting langauge called VBScript. VBScript is a scaled-back (drasticly) version of Visual Basic and is only supported by Internet Explorer...



Inserting into HTML

To insert any script into HTML, use the <script> tag. Put the script tag inside the <head> tag.
Here's the syntax:

<html>
<head>
<script language="javascript or vbscript">
<!--
You're code goes here
'//>
</script>
</head>
<body>
This is a script page!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
</body>
</html>

The comment tags (<!-- and -->) hide the text from older browsers. On the end comment tag, you
need to put a scripting comment (// for JS and ' for VBS)...


Diolauge Boxes

Diolauge boxes are supported by both JS and VBS. VBS gives you more control over the outcome of the box, however.
Here's some samples:

Javascript

<script language="javascript">
<!--
alert ("Hello, World!)
//-->
</script>

VbScript:

<script language="vbscript">
<
MsgBox "Hello, World!", 64, "Hi!"
'-->
</script>

To view a table on the different numbers and the MSgBox function, view our VB Tutorial.


Printing to the Screen

To write text to the screen, you can use JS or VBS. This useful for adding more text when a button is pressed.

Javascript


<html>
<head>
<script language="javascript">
<!--
function updatetext() {
document.write ("Howdy!")
}
//-->
</head>
<body>
<input type="button" value="Say Hi!" id="hi" onClick="javascript:updatetext()">
</body>
</html>

VBScript

<html>
<head>
<script language="vbscript">
<!--
Sub updatetext()
Print "Howdy!"
End Sub
'-->
</head>
<body>
<input type="button" value="Say Hi!" id="hi" onClick="vbscript:updatetext">
</body>
</html>

These examples will put the text "Howdy!" on the screen when the button is pressed.


What They Were Based On

Javascript was based on Java, which in turn was based on C++.
VBScript was based on Visual Basic.