Lesson 8
Lets see how we can make VBScript to work for us.
Here are few details you need to know.
Write a procedure and call it to Print out HTML text
|
<HTML>
<SCRIPT LANGUAGE="VBSCRIPT">
<BODY BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="VBSCRIPT">
</BODY> </HTML> |
Yet another VBScript feature
Random messages
Generate a random welcome message every time a user visits the page.
|
<HTML>
<SCRIPT LANGUAGE="VBSCRIPT">
Randomize Greeting(0) = "Hello there!"
Quote = Int(Rnd() * 5)
<BODY BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="VBSCRIPT">
</BODY> </HTML> |
Case by case decisions
Use the Select Case structure to choose from a large number of possible choices.
|
<HTML>
<BODY BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="VBSCRIPT">
Select Case MonthName(Month(Date))
</BODY> </HTML> |
ActiveX Controls
A note about ActiveX controls Microsoft has abandonded them . If you've dealt with Microsoft before, you'll understand why this happened: ActiveX controls were the flavor the month when IE 3.0 came out. Microsoft created brand awareness, promoted the heck out of it, feeded developers with all the info they needed.Then they abandoned them.
The ActiveX control as we know it (that is, you and I) is dead.
Why is that, you ask? Well, something better came along, as it often does, and like the ActiveX control before it, this new technology is also very much Microsoft-specific. It's called Dynamic HTML, a valiant attempt at melding scripting (either VBScript or JavaScript). Using Dynamic HTML, you can do just about everything you ever did with ActiveX controls . In fact, Dynamic HTML is the Next Big Thing if you're a VBScripter.
For those of you still interested in knowing how to interact with ActiveX controls, we need to talk about ActiveX Control Pad.
Scripting Object Model
| Property | What it is |
| defaultStatus | The default text that will appear in the current window's status bar. |
| document | The Document object for the current window. |
| frames | The list of frames for the current window. |
| history | The History object for the current window. |
| location | The Location object for the current window. |
| name | The name of the current window. |
| navigator | The Navigator object for the current window. |
| opener | The Window object that opened the current window. |
| parent | The frame that contains the current window. |
| self | The Window object of the current window. |
| status | Used to set the text in the current window's status bar. |
| top | The topmost window's Window object. |
| Method | What it is |
| alert | Displays a dialog box with an alert message. |
| clearTimeout | Clears a particular timer. |
| close | Closes the current browser window. |
| confirm | Displays a dialog box with OK and Cancel choices. |
| navigate | Navigates the window to a new URL. |
| open | Opens a new browser window. |
| prompt | Prompts the user for input using a dialog box. |
| setTimeout | Calls a function after a period of time has elapsed. |
| Event | When it occurs |
| onLoad | Occurs when the page in the window has fully loaded. |
| onUnload | Occurs when the page in the window closes. |
Further Info about Scriting Object Model