free software download
Windows free Download Mac free Download Linux free Download Dirvers free Download Advanced Search
     Drivers download     Submit your software     Top Downloads     Promote Software     Advertise     Link Exchange     Free Tutorial
Welcome to Activex Tutorial
  FREE ONLINE TUTORIAL:
Microsoft Access Tutorial
C++ Tutorial
CSS Tutorial
HTML Tutorial
JavaScript Tutorial
Vbscript Tutorial
Visual Basic Tutorial
Oracle Tutorial
Perl Tutorial
RedHat Linux Tutorial
TCP/IP Tutorial
Unix Tutorial
Visual C++ Tutorial
SQL Tutorial
WML Tutorial
XML Tutorial
ActiveX Tutorial
CGI Tutorial
Java Games Tutorial
Visual Interdev Tutorial
JAVA Tutorial
WINNT Tutorial
DHTML Tutorial
XHTML Tutorial
XSL Tutorial

Programming Inside the Internet Explorer


Previous Next



Chapter Five

Programming Inside the Internet Explorer

Introduction

Today you will learn to exploit the programming power that lives inside Microsoft Internet Explorer. Internet Explorer presents a rich set of internal objects, properties, and methods, along with scripting and ActiveX components, that you can use to build smarter, more interactive Web sites. By the end of the day you, will know how to use:

  • The main object in Internet Explorer, Window.

  • Window's 11 properties.

  • Windows's 8 methods.

  • Windows' 2 events.


Why Internet Explorer?


There are several Web browsers available for the Internet today. The two primary browsers are Netscape Navigator (http://www.netscape.com/) and Microsoft Internet Explorer (http://www.microsoft.com/). Currently, Internet Explorer is the only browser that supports VBScript and ActiveX controls, so you will be running your scripts and ActiveX controls on it.

The internal object model for Netscape Navigator is similar to the one for Internet Explorer, so what you learn today will at least give you a good start if you ever wind up putting ActiveX components in Netscape Navigator Web pages.

Internet Explorer Object Model


This section has two objectives. First, detail the objects available to the programmer. Second, show how these objects are manipulated through scripting. I will use both VBScript and JavaScript in the examples. Don't worry about the syntax, that's what days 6 and 7 are for.

For those of you who are new to programming, an object is a collection of properties and methods. A window on your computer screen is an object. The window has properties, such as background color, size, and border type. The window also has methods. Methods are ways of doing things. A window usually has a method for expanding itself to fill the whole screen, and another method to reduce itself to an icon. Events are the object's methods that are triggered by the operating system. A good example of an event is clicking your mouse button when the cursor is over a button. By clicking the mouse, you cause the operating system to call the OnClick method of the button. The programmer can place code in this method. You placed code in this event in yesterday's ActiveX Control Pad example, and will be putting code inside events in almost every example you do today.

The Window: Mother of all Objects


The object at the top of the chart is the window object . This object contains 11 properties, 8 methods and 2 events. Lets start with window's properties.

Window Properties


The 11 window properties are
Name—This property is the name of the current window. To have a name, a window must be created by:

-Using the window.open method (not currently implemented):

<SCRIPT Language="VBScript">
window.open ( "sample.asp", "mywindow");

-Creating the window with a name using the FRAMESET element:

<FRAMESET ROWS="50%, *">
<FRAME NAME="firstframe" SRC="minibrws.asp">
<FRAME NAME="secondframe" SRC ="name.asp" >
</FRAMESET>

Creating the window with a URL using the TARGET attribute:


<A HREF="Name.asp" TARGET="secondframe">Launch Name Frame </A>

Parent—This property is the window object that is the parent of the current window. Because it is a window object, the parent property possesses all the objects, methods, and events that come with being a window.

Self—This property is the window object of the current window. This object is redundant. For example, the current window could reference its name by either window.name or by self.name; both refer to the name of the current window.

Top—This property is the window object of the top-most window in a collection of windows. This is the object that owns all the frames in a given browser window. For example, to get the name of the top-most window, use:

string1 = top.name

DefaultStatus—This property is the default text displayed in the lower-left corner of the status bar. This doesn't currently set the default status, but it does set the text that appears in the left part of the status bar. You will shortly do an example that shows defaultstatus in action.

Status—This property changes the text in the lower-left corner of the status bar.(not currently implemented).

Script—This property contains all the functions defined within the <SCRIPT> tags in a window. The browser uses this object to track the functions that are loaded by your scripts.

Location—This property is the location object for the window. It contains the properties href, protocol, host, hostname, port, pathname, search, and hash. The most commonly used of these properties is href. For example, to put the current URL in a variable called string1 you would write:

string1 = window.location.href

Frames—This property is a zero-based array of frames for the current window. The frame object can be used like a window object. For example, the name of the first frame is

window.frame(0).name

History—This property is an object that contains data from the browser's history list. This object contains three methods (Forward, Back, and Go) and one property (length). Forward and Back work just like pushing the Forward and Back buttons on the Explorer to get to other Web pages on the history list. Go moves you a given number of pages from the beginning of the list. Length tells us how long the list is (currently not implemented).

Navigator—This property is an object that contains information about the browser. This information is contained in four properties, appCodeName, appName, appVersion, and userAgent. In the 3.0 version of Internet Explorer, these properties have the following values (notice how Internet Explorer 3.0 makes itself look like Netscape with the AppCodeName and the userAgent):

AppCodeName—Mozilla

appName—Microsoft Internet Explorer

appVersion—2.0 (compatible; MSIE 3.0A; Windows 95)

userAgent—Mozilla/2.0 (compatible; MSIE 3.0A; Windows 95)

Document—This property is an object that contains references to all of the major elements of a Web page. The properties associated with document are

linkColor, aLinkColor, vLinkColor—The color of the links, highlighted links, and visited links, respectively.

bgColor, fgColor—The foreground and background colors.

Anchors—An array of anchors (<A> tags) in the document.

Links—An array of links in the document.

Forms—An array of forms in the document

lastModified—The date the page was last modified.

Title—The title of the document, from the <TITLE> Tag.

Cookie—A text file the document can create, store information to, and retrieve information from, like a Windows ini file. An in-depth discussion of cookies is beyond the scope of this guide, but if you have been using Internet Explorer for a while, you will have a collection of cookies in a subdirectory named cookies off your Windows directory.

Referrer—The URL of the program that launched this Web page.

Document methods are

write—writes data to the current document.

Writeln—writes data to the current document with a new-line character at the end. HTML ignores the new-line character unless the section is enclosed in a <PRE> tag.

Open—Opens the document for writing. Clears the page of any current text.

Close—Closes the document

Clear—Closes the document output stream and writes data to the screen. Similar to Flush in the C language. (Not implemented in this build.)

The following code segment would cause the Navigator properties to be printed on the page.

window.document.open
window.document.writeln("<PRE>")
window.document.writeln(window.navigator.appCodeName )
window.document.writeln(window.navigator.appName )
window.document.writeln(window.navigator.appVersion )
window.document.writeln(window.navigator.useragent )
window.document.writeln("</PRE>")
window.document.close

Lets go through some examples to see how these properties work.

Examples


Launch the ActiveX Control Pad. Before I do anything, go to the Tools menu, choose Options, then choose Scripting. Change the Scripting option to VBScript. The following example is built using VBScript . This is the only place you can change this option. Your screen should look like Figure 5.1.

Figure 5.1. Changing the Scripting option.

Next, build two HTML inserts . Both have a label, a text box, and a button. Make the inserts look like Figure 5.2.

Figure 5.2. Sample window object.

Save the insert with the Name label as names.alx, and save the other insert as chngstat.alx. In names.alx, add the following code to the click method of CommandButton1 (use the Script Wizard to find it). CommandButton1 is the default name the ActiveX Control Pad gives to the first button you put on your form.


TextBox1.Text = window.name

Then, in the click method of the CommandButton1 in names.alx, add this line of code:


Window.DefaultStatus = Textbox1.Text

Also, put some text in the Text property of TextBox1. Otherwise, you will get an error if you push the button without putting any text in the text box. However, its not a fatal error, so you might want to try it when you run these forms.

Create two new HTML documents. Insert names.alx into one, and save it as names.asp. Insert chngstat.alx into the other, and save it as chngstat.asp.

names.asp and chngstat.asp should look like Listing 5.1 and Listing 5.2

Listing 5.1. names.asp

<HTML>
<HEAD>
<TITLE>Names</TITLE>
</HEAD>
<BODY>
<OBJECT CLASSID="CLSID:812AE312-8B8E-11CF-93C8-00AA00C08FDF"
ID="names_alx" STYLE="LEFT:0;TOP:0">
<PARAM NAME="ALXPATH" REF VALUE="file: \source\chap05\name.alx">
</OBJECT>
</BODY>
</HTML>

Listing 5.2. chngstat.asp

<HTML>
<HEAD>
<TITLE>New Page</TITLE>
</HEAD>
<BODY>
<OBJECT CLASSID="CLSID:812AE312-8B8E-11CF-93C8-00AA00C08FDF"
ID="chngstat_alx" STYLE="LEFT:0;TOP:0">
<PARAM NAME="ALXPATH" REF VALUE="file: \source\chap05\chngstat.alx">
</OBJECT>
</BODY>
</HTML>

The alx files should look like Listing 5.3 and Listing 5.4.

Listing 5.3. name.alx

<SCRIPT LANGUAGE="VBScript">
<!--
Sub CommandButton1_Click()
TextBox1.Text = window.name
end sub
-->
</SCRIPT>
<DIV ID="Layout1" STYLE="LAYOUT:FIXED;WIDTH:215pt;HEIGHT:124pt;">
<OBJECT ID="CommandButton1"
CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
STYLE="TOP:78pt;LEFT:70pt;WIDTH:70pt;

HEIGHT:23pt;TABINDEX:0;ZINDEX:0;">
<PARAM NAME="Caption" VALUE="Push Me">
<PARAM NAME="Size" VALUE="2469;811">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="3">
</OBJECT>
<OBJECT ID="TextBox1"
CLASSID="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3"
STYLE="TOP:39pt;LEFT:0pt;WIDTH:211pt;

HEIGHT:14pt;TABINDEX:1;ZINDEX:1;">
<PARAM NAME="VariousPropertyBits" VALUE="746604571">
<PARAM NAME="Size" VALUE="7444;494">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
</OBJECT>
<OBJECT ID="Label1"
CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0" STYLE="TOP:16pt;LEFT:70pt;WIDTH:70pt;HEIGHT:16pt;ZINDEX:2;">
<PARAM NAME="Caption" VALUE="Name">
<PARAM NAME="Size" VALUE="2469;564">
<PARAM NAME="FontName" VALUE="Times New Roman">
<PARAM NAME="FontHeight" VALUE="240">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="3">
</OBJECT>
</DIV>

Listing 5.4. chngstat.alx

<SCRIPT LANGUAGE="VBScript">
<!--
Sub CommandButton1_Click()
Window.DefaultStatus = Textbox1.Text
end sub
-->
</SCRIPT>
<DIV ID="Layout1" STYLE="LAYOUT:FIXED;WIDTH:217pt;HEIGHT:121pt;">
<OBJECT ID="CommandButton1"
CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
STYLE="TOP:78pt;LEFT:70pt;WIDTH:70pt;

HEIGHT:23pt;TABINDEX:0;ZINDEX:0;">
<PARAM NAME="Caption" VALUE="Push Me">
<PARAM NAME="Size" VALUE="2469;811">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="3">
</OBJECT>
<OBJECT ID="TextBox1"
CLASSID="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3" STYLE="TOP:39pt;LEFT:0pt;WIDTH:211pt;

HEIGHT:14pt;TABINDEX:1;ZINDEX:1;">
<PARAM NAME="VariousPropertyBits" VALUE="746604571">
<PARAM NAME="Size" VALUE="7444;494">
<PARAM NAME="Value" VALUE="Some Default Text">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
</OBJECT>
<OBJECT ID="Label1"
CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0" STYLE="TOP:16pt;LEFT:62pt;WIDTH:86pt;HEIGHT:16pt;ZINDEX:2;">
<PARAM NAME="Caption" VALUE="Status Message">
<PARAM NAME="Size" VALUE="3034;564">
<PARAM NAME="FontName" VALUE="Times New Roman">
<PARAM NAME="FontHeight" VALUE="240">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="3">
</OBJECT>
</DIV>

At this point, if you run names.asp and push the button, the text box remains blank. Remember that there were only three ways to name a window (window.open, <FRAMESET>, and TARGET). Lets try one of them. To get a better look at what the name property does, create a new form using <FRAMESET> and add two lines of code to your existing forms.

Use a text editor and create the following as frame.asp:

Listing 5.5. Source for frame.asp

<HTML>
<FRAMESET ROWS="50%, *">
<FRAME NAME="firstframe" SRC="name.asp">
<FRAME NAME="secondframe" SRC ="name.asp" >
</FRAMESET>
</HTML>

This splits the screen into two frames, named "firstframe" and "secondframe", and loads name.asp into both frames. Now add the line

<A HREF="chngstat.asp" TARGET="secondframe">Change Status </A>

to the name.asp file on the line following the </OBJECT> tag. This line will load chngstat.asp into "secondframe". Save the file. Now add the line

<A HREF="Name.asp" TARGET="secondframe">Launch Name Frame </A>

to the chngstat.asp file on the line following the </OBJECT> tag. This calls names.asp back into "secondframe". Save the file and bring up frame.asp in your browser. After clicking both Push Me buttons, your screen should look like Figure 5.3.

Figure 5.3. Seeing double.

The truth comes out! windows.name is the name of the <FRAME> where the window is loaded. Clicking the Change Status link, adding some text to the text box, and pushing the button results in Figure 5.4.

Figure 5.4. Status change.

Notice the status change . Notice how the window object and the text box are manipulated the same way by VBScript. When you set the text box text, you used TextBox1.Text. You used the same syntax for window.name.


Using the Object Name
The preceding example works just as well if you use name instead of window.name. However, this is a bad habit to get into. For example, if you misspell name as nane, VBScript uses the new variable nane . Mistakes like this can take some time to find. However, if you use window.nane, you get an error telling you window doesn't support a nane when you run the form in the browser.


Lets look at some of the other interesting properties. The following example looks simple, but it does some cool stuff.

Put three labels, a button, and a text box on a form using ActiveX. The physical layout should look like Figure 5.5.

Figure 5.5. Status change.

Using the Script Wizard , add the following code to the Onload Event for the layout control:

 

Label1.Caption = window.location.href
Then, quick like a bunny, add the following

code to your friend, the CommandButton1's click event:

parent.frames(1).location.href = TextBox2.Text

label1.caption = parent.frames(1).location.href
Then save the insert as minibrs.alx.

Your source code should look like Listing 5.6.

Listing 5.6. minibrs.alx

<SCRIPT LANGUAGE="VBScript">
<!--
Sub Layout2_OnLoad()
Label1.Caption = window.location.href
end sub
-->

</SCRIPT>

<SCRIPT LANGUAGE="VBScript">

<!--
Sub CommandButton1_Click()

parent.frames(1).location.href = TextBox2.Text
label1.caption = parent.frames(1).location.href

end sub
-->

</SCRIPT>

<DIV ID="Layout2" STYLE="LAYOUT:FIXED;WIDTH:262pt;HEIGHT:122pt;">

<OBJECT ID="Label2"
CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0" STYLE="TOP:0pt;LEFT:23pt;WIDTH:203pt;HEIGHT:15pt;ZINDEX:0;">

<PARAM NAME="VariousPropertyBits" VALUE="276824091">

<PARAM NAME="Caption" VALUE="Location of Web Page in Lower Frame">

<PARAM NAME="Size" VALUE="7161;529">

<PARAM NAME="FontHeight" VALUE="240">

<PARAM NAME="FontCharSet" VALUE="0">

<PARAM NAME="FontPitchAndFamily" VALUE="2">

<PARAM NAME="ParagraphAlign" VALUE="3">

</OBJECT>

<OBJECT ID="Label3"

CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0" STYLE="TOP:47pt;LEFT:70pt;WIDTH:109pt;HEIGHT:16pt;ZINDEX:1;">

<PARAM NAME="Caption" VALUE="I Want to Go To">

<PARAM NAME="Size" VALUE="3845;564">

<PARAM NAME="FontHeight" VALUE="280">

<PARAM NAME="FontCharSet" VALUE="0">

<PARAM NAME="FontPitchAndFamily" VALUE="2">

<PARAM NAME="ParagraphAlign" VALUE="3">

</OBJECT>

<OBJECT ID="CommandButton1"

CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57" STYLE="TOP:70pt;LEFT:195pt;WIDTH:23pt;

HEIGHT:24pt;TABINDEX:2;ZINDEX:2;">

<PARAM NAME="Caption" VALUE="GO!">
<PARAM NAME="Size" VALUE="811;847">
<PARAM NAME="FontCharSet" VALUE="0">

<PARAM NAME="FontPitchAndFamily" VALUE="2">

<PARAM NAME="ParagraphAlign" VALUE="3">

</OBJECT>

<OBJECT ID="TextBox2"

CLASSID="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3" STYLE="TOP:70pt;LEFT:31pt;WIDTH:156pt;

HEIGHT:24pt;TABINDEX:3;ZINDEX:3;">

<PARAM NAME="VariousPropertyBits" VALUE="746604571">

<PARAM NAME="Size" VALUE="5503;847">

<PARAM NAME="FontCharSet" VALUE="0">

<PARAM NAME="FontPitchAndFamily" VALUE="2">

</OBJECT>
<OBJECT ID="Label1"
CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0" STYLE="TOP:23pt;LEFT:23pt;WIDTH:203pt;

HEIGHT:14pt;ZINDEX:4;">

<PARAM NAME="VariousPropertyBits" VALUE="276824091">

<PARAM NAME="Caption" VALUE="URL">

<PARAM NAME="Size" VALUE="7161;494">

<PARAM NAME="FontName" VALUE="Times New Roman">

<PARAM NAME="FontEffects" VALUE="1073741825">

<PARAM NAME="FontHeight" VALUE="240">

<PARAM NAME="FontCharSet" VALUE="0">

<PARAM NAME="FontPitchAndFamily" VALUE="2">

<PARAM NAME="ParagraphAlign" VALUE="3">

<PARAM NAME="FontWeight" VALUE="700">

</OBJECT>

</DIV>

Place minibrs.alx inside a new HTML page, and save them as minibrs.asp. Create a frame page to hold minibrs.asp . Use the source code in Listing 5.7, and save it as brsfram.asp.

Listing 5.7. brsfram.asp

<HTML>
<FRAMESET ROWS="50%, *">
<FRAME NAME="firstframe" SRC="minibrws.asp">
<FRAME NAME="secondframe" SRC ="name.asp" >
</FRAMESET>
</HTML>

Figure 5.6. A browser in a browser.

The secret to this program is in the object's parent, frames, and location. The parent object in this case is the window created by brsfram.asp. The parent object contains an zero-based (frame(0) is the first frame, frame(1) is the second, and so on) array of frames that can be addressed like the windows object in the first example. The third object you use is location. Location has the property href, which you read (label1.caption = parent.frames(1).location.href) and wrote to (parent.frames(1).location.href = TextBox2.Text) in the example. Another object, history, gives you access to a listing of all the pages you have browsed; you can traverse this URL list by using the Forward, Back, and Go buttons. At the time of this writing, the history object was not yet supported by the browser.

You have seen what objects are available to the developer through the browser and how to access them using VBScript. Most of the objects not covered in the last two examples will be covered during the rest of the discussion of VBScipt.

Window Methods


The window object offers nine methods.

  • Alert—This is a dialog box with an optional string message. The command Alert brings up an empty dialog with an OK button. Coding Alert, This Space for hire, puts the text on a dialog and show the dialog on the screen (see Figure 5.7).

Figure 5.7. Alert in action.

  • Confirm—This is a dialog box with an optional string message, OK and CANCEL buttons, and a Boolean return value that depends on which button the user presses.

Figure 5.8. To confirm or not to confirm.

  • Prompt—This is a dialog with a text field that shows a default string(if defined by the programmer) and returns the string entered by the user.

Figure 5.9. The Prompt dialog.

  • Open, Close—These are used to open and close another instance of the Internet Explorer (not implemented in Internet Explorer 3.0).

  • SetTimeout, ClearTimeout—These are used to set and clear a timer.

  • Navigate—This is used to load a URL into a window.
Window Events

There are two window object events :

Onload—This is fired when the window is loaded, and is a good place for initialization code.

Unload—This is fired when the window is closed, and is a good place for cleanup or thank you messages.

Get out your text editor and create the following:

Listing 5.8. A collection of Dialogs, boxes.asp

<HTML>
<HEAD>
<TITLE>Boxes</TITLE>
<SCRIPT LANGUAGE="VBScript" >
<!--
Sub LoadMe()
Alert "This Space for Rent"
Answer = Confirm("Launch the Shuttle?")
String1 = Prompt("Enter Here","Defaulted Text")
Alert string1
end sub
Sub OutofHere()
Alert "Thats All Folks"
end sub
-->
</SCRIPT>
</HEAD>
<BODY Language="VBS" onLoad="LoadMe"

onUnload = "OutofHere">
</BODY>
</HTML>

Save this source code as boxes.asp and run it in the browser. Notice how the onLoad and onUnload events are assigned to the subroutines Loadme and OutofHere in the line

<BODY Language="VBS" onLoad="LoadMe" onUnload = "OutofHere">

Also, notice how the default text for the text box(where the user can enter a value) in the prompt is entered

String1 = Prompt("Enter Here","Defaulted Text")

Lets do another example. Launch the ActiveX Control Pad and change the scripting language to JavaScript (Tools|Options|Script). Create one HTML insert, and attach an image control called Image1. Save the HTML insert as chngpix.alx. Open a New HTML file. Using the Script Wizard, add the variables MyTimer and PicState. Then add the procedure ChangePic(). In the window.onload, window.onunload and ChangePic event put the code shown in Listing 5.9.

Listing 5.9. chngpix.asp

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
var MyTimer
var PicState
function ChangePic()
{
if (PicState=1)
{
chngpix_alx.Image1.PicturePath = "pow.gif";
Picstate = 2;
}
else
{
chngpix_alx.Image1.PicturePate = "caution.gif";
Picstate = 1;
}
MyTimer = window.setTimeout('ChangePic()', 50000)}
-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" FOR="window" EVENT="onLoad()">
<!--
MyTimer = window.setTimeout('ChangePic()', 500);
PicState = 1;
-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" FOR="window" EVENT="onUnload()">
<!--
window.clearTimeout(MyTimer)
-->
</SCRIPT>
<TITLE>New Page</TITLE>
</HEAD>
<BODY>
<OBJECT CLASSID="CLSID:812AE312-8B8E-

11CF-93C8-00AA00C08FDF"
ID="chngpix_alx" STYLE="LEFT:0;TOP:0">
<PARAM NAME="ALXPATH" REF VALUE= "file: \source\chap05\chngpix.alx">
</OBJECT>
</BODY>
</HTML>

Save this as chngpix.asp. Listing 5.10 shows chngpix.alx.

Listing 5.10. chngpix.alx

<DIV ID="Layout4" STYLE="LAYOUT:FIXED;WIDTH:453pt;HEIGHT:275pt;">

<OBJECT ID="Image1"

CLASSID="CLSID:D4A97620-8E8F-

11CF-93CD-00AA00C08FDF" STYLE="TOP:16pt;LEFT:8pt;

WIDTH:110pt;HEIGHT:94pt;ZINDEX:0;">


<PARAM NAME="BorderStyle" VALUE="0">


<PARAM NAME="SizeMode" VALUE="3">


<PARAM NAME="Size" VALUE="3900;3302">


<PARAM NAME="PictureAlignment" VALUE="0">


<PARAM NAME="VariousPropertyBits" VALUE="19">


</OBJECT>

</DIV>

When you run this in your browser, the picture, Pow.gif, will flash about one time per second and will look like Figure 5.10. Only yours will be flashing, the one here on the page will not. You can get the same effect by opening and closing the guide quickly.

Figure 5.10 Its' flashing!.

One thing to note about this code is the reference to the image control from outside the layout control. The image control is referenced as chngpix_alx.Image1. It is not accessible as Image1 from outside the layout control. This allows you to reference any piece inside the layout control. You can create clusters of controls, such as a toolbar, and access the same alx component from many different forms.

You have seen what objects are available to the developer through the browser and how to access them using VBScript and JavaScript. During the course of the rest of the week, you will use window and its properties, methods, and events over and over again.

Summary


Today you looked inside the Internet Explorer and found the mother of all objects, window. You can use window's built-in functions to make your Web pages more expressive. Tomorrow you will add VBScript to your tool chest.

Q&A


  • Q I read in the ActiveX Help that a certain function was not implemented, but it worked when I used it. What gives?

  • A Browser software and the tools to support it are still in their infancy. I think you are about to see them go through a very fast adolescence. Someday they might move out of the house and leave us alone. No, wait, that last line applies to my kids. Forget that line, but remember that Internet publishing and programming are in a state of flux. Keep trying the functions that didn't work on your last beta!

  • Q Who is driving the Web Browser standard boat? Every thing keeps changing so quickly!

  • A The HTML standard that is the key to this technology is public. However, JavaScript, VBScript, Netscape Navigator, and Internet Explorer all represent proprietary standards. This is good and bad. The good thing is that a proprietary standard evolves more quickly than a public standard. The bad thing is that competition takes some proprietary standards out of the marketplace.

  • Q Will Netscape Navigator support VBScript and ActiveX?

  • A The is an plug-in for Netscape Navigator that supports VBScript and ActiveX.

Workshop


Rewrite the example in Listing 5.6 (brsfram.asp, minibrs.alx, and minbrs.asp) to use the Window object's Onload event instead of Layout.onload. Also, use the window.navigate method instead of the frame(1).location.href to load the user-selected window. Use the window.unload event to display a farewell message.

Quiz

  1. What would happen if you typed window.mane instead of window.name, then tried to assign it to a text box? What if you typed mane instead of name?

  2. What object or function can you use to write directly to the Web page from within the Web page?

  3. What HTML tag do I use to break my screen into smaller windows? What attribute inside that component sets the name of the new region?



Previous Next



Your ad here!
Advertise on
Softlookup.com



Your ad here!
Advertise on
Softlookup.com
Free tutorial
MS Access
C++
CSS
HTML
JavaScript
Vbscript
Visual Basic
Oracle
Perl
RedHat Linux
TCP/IP
Unix
Visual C++
SQL
WML
XML
ActiveX
CGI
Java Games
Visual Interdev
JAVA
WINNT
DHTML
XHTML
XSL Tutorial
Home | About us | Categories | New Releases | Most Popular | Web tutorial | IT News | Drivers | Submit a program |   
2013 SoftLookup Corp. Privacy Statement