1 | <HTML>
|
---|
2 | <!-- This file is part of the HTML Reference Library ('HTMLib') -->
|
---|
3 | <!-- It should not be used outside of the HTMLib package -->
|
---|
4 | <!-- The HTMLib is © 1995-1998 Stephen Le Hunte -->
|
---|
5 | <!-- htmlib@htmlib.demon.co.uk -->
|
---|
6 | <HEAD>
|
---|
7 | <LINK REL="stylesheet" HREF="../style.css" TYPE="text/css">
|
---|
8 | <TITLE>The Window object</TITLE>
|
---|
9 | </HEAD>
|
---|
10 | <BODY TOPMARGIN="0" BGCOLOR="#FFFFE0" TEXT="#000000" LANGUAGE="JavaScript">
|
---|
11 |
|
---|
12 | <CENTER>
|
---|
13 | <SPAN CLASS="NSRtitle">The Window Object</SPAN>
|
---|
14 | </CENTER>
|
---|
15 |
|
---|
16 | <P><A NAME="top">The</A> <CODE>Window</CODE> object is the top level object and represents the window of the browser. It is the parent of the objects below it in the hierarchy list.
|
---|
17 |
|
---|
18 | <P>Window objects are either the current window (if the browser is displaying only a single document), or those created with a <CODE>window.open()</CODE> method (where the name is specified in the code), or separate frames, if the document is laid out using a <CODE><A HREF="../Frames/fset.htm"><FRAMESET></A></CODE> definition (where the windows are named in the <CODE><A HREF="../Frames/frame.htm"><FRAME></A></CODE> element). As the <CODE>Window</CODE> object is the top level object in the object hierarchy and the existance of the current window is assumed, most <CODE>Window</CODE> properties need not be prefixed by <CODE>Window.</CODE> For example, the following two references are identical :
|
---|
19 |
|
---|
20 | <SPAN CLASS="egcode">
|
---|
21 | <BLOCKQUOTE>
|
---|
22 | <CODE>window.defaultStatus<BR>
|
---|
23 | defaultStatus
|
---|
24 | </CODE>
|
---|
25 | </BLOCKQUOTE>
|
---|
26 | </SPAN>
|
---|
27 |
|
---|
28 | <P>and would both return the default text of the status bar for the current window. <STRONG><EM>NOTE : </EM></STRONG>The only exception to this is the <CODE>open()</CODE> and <CODE>close()</CODE> methods, which require an explicit <CODE>window.</CODE> prefix (i.e. <CODE>window.open()</CODE> and <CODE>window.close()</CODE>). Windows can also be referenced by using the properties <CODE>top</CODE>, <CODE>parent</CODE> or <CODE>name</CODE>, where the name property is replaced with the actual window name (as specified in the <CODE>window.open()</CODE> code, or <CODE><FRAMESET></CODE>. The <CODE>parent</CODE> and <CODE>top</CODE> properties are exactly as those used in <CODE><A HREF="../Frames/frame.htm#NAME"><A HREF="..." TARGET="..."></A></CODE> constructs if the windows are part of a frameset.
|
---|
29 |
|
---|
30 | <P><STRONG><A NAME="props">Window Properties</A></STRONG><BR>
|
---|
31 | <STRONG><A NAME="client">client</A></STRONG><BR>
|
---|
32 | The <CODE>client</CODE> property reflects the <A HREF="navo.htm" TITLE="View the Navigator Object topic">Navigator Object</A> and can be used to retrieve information about the browser client.
|
---|
33 |
|
---|
34 | <P><STRONG><A NAME="closed">closed</A></STRONG><BR>
|
---|
35 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>closed</CODE> property has a read-only boolean value, which represents whether the referenced window is closed (<CODE>closed=true</CODE>) or not (<CODE>closed=false</CODE>).
|
---|
36 |
|
---|
37 | <P><STRONG><A NAME="defaultStatus">defaultStatus</A></STRONG><BR>
|
---|
38 | The <CODE>defaultStatus</CODE> property can be accessed to return or set the text to be shown in the status bar of the browser while the current document. The <CODE>defaultStatus</CODE> property is different to the <CODE>status</CODE> property in that the text is always shown in the status bar. As seen below, the <CODE>status</CODE> property can be used to temporarily alter the status bar text. <STRONG>Internet Explorer</STRONG> currently set this property as the default status text and so works as the <CODE>status</CODE> property.
|
---|
39 |
|
---|
40 | <P><STRONG><A NAME="dialogArguments">dialogArguments</A></STRONG><BR>
|
---|
41 | The <CODE>dialogArguments</CODE> property returns any arguments that were used when the referenced modal dialog window was created. Note that this property only applies to windows created with the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method section"><CODE>showModalDialog</CODE></A> method. For example, if the following is used to open a modal dialog window:
|
---|
42 |
|
---|
43 | <SPAN CLASS="egcode">
|
---|
44 | <BLOCKQUOTE>
|
---|
45 | <CODE>self.showModalDialog "dialog.htm", "Enter search string"
|
---|
46 | </CODE>
|
---|
47 | </BLOCKQUOTE>
|
---|
48 | </SPAN>
|
---|
49 |
|
---|
50 | <P>and <CODE>dialog.htm</CODE> contains a text box (with an <CODE>ID</CODE> attribute of <CODE>txtSearch</CODE>), then running:
|
---|
51 |
|
---|
52 | <SPAN CLASS="egcode">
|
---|
53 | <BLOCKQUOTE>
|
---|
54 | <CODE>txtSearch.value=window.dialogArguments
|
---|
55 | </CODE>
|
---|
56 | </BLOCKQUOTE>
|
---|
57 | </SPAN>
|
---|
58 |
|
---|
59 | <P>would put the text "Enter search string" into the text box.
|
---|
60 |
|
---|
61 | <P><STRONG><A NAME="dialogHeight">dialogHeight</A></STRONG><BR>
|
---|
62 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>dialogHeight</CODE> property reflects the height of the referenced modal dialog window. It is set as one of the features in the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method"><CODE>showModalDialog</CODE></A> method.
|
---|
63 |
|
---|
64 | <P><STRONG><A NAME="dialogLeft">dialogLeft</A></STRONG><BR>
|
---|
65 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>dialogLeft</CODE> property reflects the horizontal offset of the referenced modal dialog window, relative to the left hand edge of the desktop. It is set as one of the features in the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method"><CODE>showModalDialog</CODE></A> method.
|
---|
66 |
|
---|
67 | <P><STRONG><A NAME="dialogTop">dialogTop</A></STRONG><BR>
|
---|
68 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>dialogTop</CODE> property reflects the vertical offset of the referenced modal dialog window, relative to the top edge of the desktop. It is set as one of the features in the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method"><CODE>showModalDialog</CODE></A> method.
|
---|
69 |
|
---|
70 | <P><STRONG><A NAME="dialogWidth">dialogWidth</A></STRONG><BR>
|
---|
71 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>dialogWidth</CODE> property reflects the width of the referenced modal dialog window. It is set as one of the features in the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method"><CODE>showModalDialog</CODE></A> method.
|
---|
72 |
|
---|
73 | <P><STRONG><A NAME="document">document</A></STRONG><BR>
|
---|
74 | The <CODE>document</CODE> property references the <A HREF="doco.htm" TITLE="View the Document Object topic">The Document Object</A> for the referenced window. The document object has properties that contain information about the current document being viewed in the browser window object. For example :
|
---|
75 |
|
---|
76 | <SPAN CLASS="egcode">
|
---|
77 | <BLOCKQUOTE>
|
---|
78 | <CODE>vColour=parent.<STRONG>document</STRONG>.bgColor
|
---|
79 | </CODE>
|
---|
80 | </BLOCKQUOTE>
|
---|
81 | </SPAN>
|
---|
82 |
|
---|
83 | <P>stores the background colour of the document in the current window's parent in the variable <CODE>vColour</CODE>.
|
---|
84 |
|
---|
85 | <P><STRONG><A NAME="event">event</A></STRONG><BR>
|
---|
86 | The <CODE>event</CODE> property references the <A HREF="evento.htm" TITLE="Scroll to the Event Object">Event Object</A>, through which key and mouse states/positions can be determined for any event that occurs. Note that the Event Objects supported by both <STRONG>Internet Explorer</STRONG> and <STRONG>Netscape</STRONG> are different. Details are given in the <A HREF="evento.htm" TITLE="View the Event Object topic">Event Object</A> topic.
|
---|
87 |
|
---|
88 | <P><STRONG><A NAME="external">external</A></STRONG><BR>
|
---|
89 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>external</CODE> property can be used to reference the object model of applications that host Internet Explorer. Various properties, methods and events exposed by the host application would then be available to scripting in HTML documents being displayed in the Internet Explorer application inside the host. Two methods are inherent to the <CODE>external</CODE> property though:
|
---|
90 |
|
---|
91 | <DL>
|
---|
92 | <DT><STRONG>addChannel</STRONG><DD>Presents a user with a dialog box allowing them to add a channel to their system, or modify its properties if the channel is already installed. The <CODE>addChannel</CODE> method takes the single argument of a URL which should be the complete URL of the CDF file that defines the channel. Note that Microsoft intend this function only for publishers pre-installing channels when re-distributing <STRONG>Internet Explorer</STRONG> 4.0. As with the Internet Client SDK, it's included here for completeness.
|
---|
93 | <DT><STRONG>isSubscribed</STRONG><DD>Returns a boolean (i.e. true or false) value representing whether the user is currently subscribed to the channel referenced in the <CODE>URL</CODE> argument of the method. A scripting error will occur if the referenced channel is not in the same secondary domain (i.e. <CODE>http://beta.htmlib.com/</CODE> and <CODE>http://www.htmlib.com/</CODE> both have the same secondary domain) as the document calling the method.
|
---|
94 | </DL>
|
---|
95 |
|
---|
96 | <P>For further information on channels and information on creating channels, see the <A HREF="http://msdn.microsoft.com/workshop/delivery/channel/overview/overview.asp">Active Channel Technology Overview</A> in Microsoft's <A HREF="http://msdn.microsoft.com/workshop/">Web Workshop</A>.
|
---|
97 |
|
---|
98 | <P><STRONG><A NAME="frames">frames</A></STRONG><BR>
|
---|
99 | The <CODE>frames</CODE> property references the <A HREF="framcol.htm" TITLE="View the Frames collection topic">The Frames collection</A>. When a document is a framed document, the individual frames are indexed, starting at 0. So, for example, to access the location object of the frame defined third in the <CODE><A HREF="../Frames/fset.htm"><FRAME></A></CODE> definitions, the following could be used :
|
---|
100 |
|
---|
101 | <SPAN CLASS="egcode">
|
---|
102 | <BLOCKQUOTE>
|
---|
103 | <CODE>vLocation=window.<STRONG>frames(2)</STRONG>.location
|
---|
104 | </CODE>
|
---|
105 | </BLOCKQUOTE>
|
---|
106 | </SPAN>
|
---|
107 |
|
---|
108 | <P><STRONG><EM>NOTE : </EM></STRONG> The above example uses Visual Basic Script notation (i.e. '(' and ')') to denote the index. JavaScript functions require the use of square bracket ('[' and ']').
|
---|
109 |
|
---|
110 |
|
---|
111 | <P><STRONG><A NAME="history">history</A></STRONG><BR>
|
---|
112 | The <CODE>history</CODE> property is also an object in its own right, with properties and methods. For more information, see <A HREF="histo.htm" TITLE="View the History Object topic">The History Object</A>. It represents the browsers current history list (a list of recently visited sites).
|
---|
113 |
|
---|
114 | <P><STRONG><A NAME="innerHeight">innerHeight</A></STRONG><BR>
|
---|
115 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>innerHeight</CODE> property returns a value representing the referenced windows viewing area height (i.e. not including toolbars, scrollbars etc), in pixels.
|
---|
116 |
|
---|
117 | <P><STRONG><A NAME="innerWidth">innerWidth</A></STRONG><BR>
|
---|
118 | Like the <CODE>innerHeight</CODE> property, the The <STRONG>Netscape</STRONG> 4.0 specific <CODE>innerWidth</CODE> property returns a value representing the referenced windows viewing area width (i.e. not including toolbars, scrollbars etc.), in pixels.
|
---|
119 |
|
---|
120 | <P><STRONG><A NAME="length">length</A></STRONG><BR>
|
---|
121 | The <CODE>length</CODE> property returns the number of frames in a window object (when used under the <CODE>window</CODE> object. The <CODE>length</CODE> property is common to many scriptable objects). For example :
|
---|
122 |
|
---|
123 | <SPAN CLASS="egcode">
|
---|
124 | <BLOCKQUOTE>
|
---|
125 | <CODE>vFrames=HelpWin.<STRONG>length</STRONG>
|
---|
126 | </CODE>
|
---|
127 | </BLOCKQUOTE>
|
---|
128 | </SPAN>
|
---|
129 |
|
---|
130 | <P>would store the number of frames in the window named HelpWin (which is either a single frame, or a window created using the <CODE>window.open()</CODE> method) in the variable <CODE>vFrames</CODE>.
|
---|
131 |
|
---|
132 | <P><STRONG><A NAME="location">location</A></STRONG><BR>
|
---|
133 | The <CODE>location</CODE> property returns the URL of the window objects current document (because <CODE>href</CODE> is its default property). This is actually an object in its own right, with various properties. For more details, see the <A HREF="loco.htm" TITLE="View the Location Object">Location Object</A>.
|
---|
134 |
|
---|
135 |
|
---|
136 | <P><STRONG><A NAME="locationbar">locationbar</A></STRONG><BR>
|
---|
137 | In <STRONG>Netscape</STRONG> 4.0, the Window Object supports the <CODE>locationbar</CODE> property, which has a boolean property of <CODE>visible</CODE>. Setting:
|
---|
138 |
|
---|
139 | <SPAN CLASS="egcode">
|
---|
140 | <BLOCKQUOTE>
|
---|
141 | <CODE>window.locationbar.visible=false
|
---|
142 | </CODE>
|
---|
143 | </BLOCKQUOTE>
|
---|
144 | </SPAN>
|
---|
145 |
|
---|
146 | <P>would remove the referenced windows location bar. <STRONG><EM>Note : </EM></STRONG>This can only be done via a 'signed script'. For information on signed scripts, see <A HREF="http://developer.netscape.com/library/documentation/communicator/jsguide/scripts.htm" TITLE="View Netscape Developer Web site" CLASS="external" TARGET="HTMLibExternal">Netscape DevEdge Online</A>.
|
---|
147 |
|
---|
148 | <P><STRONG><A NAME="menubar">menubar</A></STRONG><BR>
|
---|
149 | As with the <CODE>locationbar</CODE> property, the <CODE>menubar</CODE> property is <STRONG>Netscape</STRONG> 4.0 specific and can be used (by setting the <CODE>visible</CODE> property to false) to remove the menu bar of the navigator window. This too requires a signed script.
|
---|
150 |
|
---|
151 | <P><STRONG><A NAME="name">name</A></STRONG><BR>
|
---|
152 | The <CODE>name</CODE> property represents the name of a window object. It is read-only (that is, script functions can interrogate window names, but can not define them dynamically)
|
---|
153 |
|
---|
154 | <P><STRONG><A NAME="navigator">navigator</A></STRONG><BR>
|
---|
155 | The <CODE>navigator</CODE> property references the <A HREF="navo.htm" TITLE="View the Navigator Object">Navigator Object</A> property. See that topic for information about the <CODE>navigator</CODE> object.
|
---|
156 |
|
---|
157 | <P><STRONG><A NAME="offscreenBuffering">offscreenBuffering</A></STRONG><BR>
|
---|
158 | When <STRONG>Internet Explorer</STRONG> 4.0 is downloading a page, it initially sets the <CODE>offscreenBuffering</CODE> property to a string value of "auto" and it decides whether offscreen buffering is necessary. This can be over-ridden in a script function, by explicitly setting the <CODE>offscreenBuffering</CODE> property to "true" or "false". Once it has been set (either way), it returns a boolean value, representing whether offscreen buffering if enabled or not.
|
---|
159 |
|
---|
160 | <P><STRONG><A NAME="opener">opener</A></STRONG><BR>
|
---|
161 | The <CODE>opener</CODE> property returns the name of the window that created the current window (via a <CODE>window.open()</CODE> event). It can be used with further object properties (such as <CODE>location</CODE> etc.) to access properties of the window/document that opened the current window, or methods such as <CODE>close()</CODE> to automatically close the window that created the current window. For example :
|
---|
162 |
|
---|
163 | <SPAN CLASS="egcode">
|
---|
164 | <BLOCKQUOTE>
|
---|
165 | <CODE>self.<STRONG>opener</STRONG>.close()
|
---|
166 | </CODE>
|
---|
167 | </BLOCKQUOTE>
|
---|
168 | </SPAN>
|
---|
169 |
|
---|
170 | <P>would automatically close the window that created the new window. Note that recent enhancements to Javascript means that the first window used (i.e. the first browser window) cannot be closed in a script without the user confirming this (a confirm? dialog box appears)
|
---|
171 |
|
---|
172 | <P><STRONG><A NAME="outerHeight">outerHeight</A></STRONG><BR>
|
---|
173 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>outerHeight</CODE> property returns a value representing the referenced windows total height (i.e. including toolbars, scrollbars etc), in pixels.
|
---|
174 |
|
---|
175 | <P><STRONG><A NAME="outerWidth">outerWidth</A></STRONG><BR>
|
---|
176 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>outerWidth</CODE> property returns a value representing the referenced windows total width (i.e. including toolbars, scrollbars etc), in pixels.
|
---|
177 |
|
---|
178 | <P><STRONG><A NAME="pageXOffset">pageXOffset</A></STRONG><BR>
|
---|
179 | The <STRONG>Netscape</STRONG> specific <CODE>pageXOffset</CODE> property reflects the difference between the current horizontal position in the page and the pages left-most edge. That is, as a page is scrolled horizontally, the <CODE>pageXOffset</CODE> will increase, or decrease, being 0 if the current viewing area <EM>is</EM> the left-most edge of the page. (<STRONG><EM>Note : </EM></STRONG> This is similar to <STRONG>Internet Explorer</STRONG>s <CODE>scrollLeft</CODE> property, but the two are incompatible)
|
---|
180 |
|
---|
181 | <P><STRONG><A NAME="pageYOffset">pageYOffset</A></STRONG><BR>
|
---|
182 | Similar to the <CODE>pageXOffset</CODE> property, the <CODE>pageYOffset</CODE> property reflects the same difference (of current vertical positions) between the current viewing area and the top-most edge of the window. (<STRONG><EM>Note : </EM></STRONG> This is similar to <STRONG>Internet Explorer</STRONG>s <CODE>scrollTop</CODE> property, but the two are incompatible)
|
---|
183 |
|
---|
184 | <P><STRONG><A NAME="parent">parent</A></STRONG><BR>
|
---|
185 | The <CODE>parent</CODE> object returns the current windows parent object if the current window is part of a frame set (if it isn't, then accessing the <CODE>parent</CODE> property returns the current window object, acting as the <CODE>self</CODE> property). For example :
|
---|
186 |
|
---|
187 | <SPAN CLASS="egcode">
|
---|
188 | <BLOCKQUOTE>
|
---|
189 | <CODE>vStrParentName=<STRONG>parent</STRONG>.name
|
---|
190 | </CODE>
|
---|
191 | </BLOCKQUOTE>
|
---|
192 | </SPAN>
|
---|
193 | <P>would store the <CODE>name</CODE> property of the parent window of the current window in the variable <CODE>vStrParentName</CODE>.
|
---|
194 |
|
---|
195 | <P><STRONG><A NAME="personalbar">personalbar</A></STRONG><BR>
|
---|
196 | In <STRONG>Netscape</STRONG> 4.0, the Window Object supports the <CODE>personalbar</CODE> property, which has a boolean property of <CODE>visible</CODE>. Setting:
|
---|
197 |
|
---|
198 | <SPAN CLASS="egcode">
|
---|
199 | <BLOCKQUOTE>
|
---|
200 | <CODE>window.personalbar.visible=false
|
---|
201 | </CODE>
|
---|
202 | </BLOCKQUOTE>
|
---|
203 | </SPAN>
|
---|
204 |
|
---|
205 | <P>would remove the referenced windows 'personal bar'. <STRONG><EM>Note : </EM></STRONG>This can only be done via a 'signed script'. For information on signed scripts, see <A HREF="http://developer.netscape.com/library/documentation/communicator/jsguide/scripts.htm" TITLE="View Netscape Developer Web site" CLASS="external" TARGET="HTMLibExternal">Netscape DevEdge Online</A>.
|
---|
206 |
|
---|
207 | <P><STRONG><A NAME="returnValue">returnValue</A></STRONG><BR>
|
---|
208 | This <STRONG>Internet Explorer</STRONG> 4.0 specific property reflects the return value of a modal dialog window, created with the <A HREF="#showModalDialog" TITLE="Scroll to the showModalDialog method">showModalDialog</A> method.
|
---|
209 |
|
---|
210 | <P><STRONG><A NAME="screen">screen</A></STRONG><BR>
|
---|
211 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>screen</CODE> property provides a reference to the <A HREF="screeno.htm" TITLE="View the Screen Object topic">Screen Object</A>, for obtaining properties of the users current resolution etc.
|
---|
212 |
|
---|
213 | <P><STRONG><A NAME="scrollbars">scrollbars</A></STRONG><BR>
|
---|
214 | Like the other <STRONG>Netscape</STRONG> 4.0 specific <CODE>*bars</CODE> properties, the <CODE>scrollbars</CODE> property has the boolean <CODE>visible</CODE> property, which can be used to remove the scroll bars from a window. Note that this can only be performed by a signed script.
|
---|
215 |
|
---|
216 | <P><STRONG><A NAME="self">self</A></STRONG><BR>
|
---|
217 | The <CODE>self</CODE> property returns the window object of the current window. For example :
|
---|
218 |
|
---|
219 | <SPAN CLASS="egcode">
|
---|
220 | <BLOCKQUOTE>
|
---|
221 | <CODE>vStrStatus=<STRONG>self</STRONG>.status
|
---|
222 | </CODE>
|
---|
223 | </BLOCKQUOTE>
|
---|
224 | </SPAN>
|
---|
225 |
|
---|
226 | <P>stores the text in the current window's status bar in the variable <CODE>vStrStatus</CODE>.
|
---|
227 |
|
---|
228 | <P><STRONG><A NAME="status">status</A></STRONG><BR>
|
---|
229 | As said above, the <CODE>status</CODE> property can be used to temporarily change the text displayed in the status bar of a browser window. It is commonly used to set the status bar text when the mouse is moved over links in a document, so that more explanatory text, instead of a URL is displayed. For example :
|
---|
230 |
|
---|
231 | <SPAN CLASS="egcode">
|
---|
232 | <BLOCKQUOTE>
|
---|
233 | <CODE>self.<STRONG>status</STRONG>="This goes to the HTMLib web site"
|
---|
234 | </CODE>
|
---|
235 | </BLOCKQUOTE>
|
---|
236 | </SPAN>
|
---|
237 |
|
---|
238 | <P>would set the text in the status bar to "This goes to the HTMLib web site". Note that when documents are presented in a frame based layout, windows don't share common access to the browsers status bar, so using <CODE>self.status</CODE> in any frame based document, may not have any effect, but accessing <CODE>top.status</CODE> would change the status bar text.
|
---|
239 |
|
---|
240 |
|
---|
241 | <P><STRONG><A NAME="statusbar">statusbar</A></STRONG><BR>
|
---|
242 | Like the other <STRONG>Netscape</STRONG> 4.0 specific <CODE>*bars</CODE> properties, the <CODE>statusbar</CODE> property has the boolean <CODE>visible</CODE> property, which can be used to remove the status bars from a window. Note that this can only be performed by a signed script.
|
---|
243 |
|
---|
244 | <P><STRONG><A NAME="toolbar">toolbar</A></STRONG><BR>
|
---|
245 | Again, the <STRONG>Netscape</STRONG> 4.0 specific <CODE>toolbar</CODE> has the boolean <CODE>visible</CODE> property, which can remove the tool bar from the navigator window. As with the other <CODE>*bar</CODE> properties, this can only be performed by a signed script.
|
---|
246 |
|
---|
247 | <P><STRONG><A NAME="top">top</A></STRONG><BR>
|
---|
248 | The <CODE>top</CODE> property returns the window object of the top-most browser window. For example :
|
---|
249 |
|
---|
250 | <SPAN CLASS="egcode">
|
---|
251 | <BLOCKQUOTE>
|
---|
252 | <CODE>vLocation=<STRONG>top</STRONG>.location
|
---|
253 | </CODE>
|
---|
254 | </BLOCKQUOTE>
|
---|
255 | </SPAN>
|
---|
256 |
|
---|
257 | <P>sets the <CODE>vLocation</CODE> variable to the complete URL of the document in the top-most browser window.
|
---|
258 |
|
---|
259 | <P><STRONG><A NAME="window">window</A></STRONG><BR>
|
---|
260 | The <CODE>window</CODE> property is a synonym for the current window. Like <CODE>self</CODE>, it references the current window.
|
---|
261 |
|
---|
262 | <P><STRONG><A NAME="methods">Window Methods</A></STRONG><BR>
|
---|
263 | <STRONG><A NAME="alert">alert</A></STRONG><BR>
|
---|
264 | The <CODE>alert</CODE> method can be used to display a message to the user. (<STRONG>Internet Explorer</STRONG> Visual Basic Script also allows the use of the <CODE>MsgBox</CODE> function to do the same, with more interaction options). For example :
|
---|
265 |
|
---|
266 | <SPAN CLASS="egcode">
|
---|
267 | <BLOCKQUOTE>
|
---|
268 | <CODE>alert "Hi there, welcome to my page"
|
---|
269 | </CODE>
|
---|
270 | </BLOCKQUOTE>
|
---|
271 | </SPAN>
|
---|
272 |
|
---|
273 | <P>would display the message "Hi there, welcome to my page" over the current window. (<STRONG><EM>NOTE : </EM></STRONG>As <CODE>alert</CODE> is a method of the window object (the top level object), it does not require the <CODE>window.</CODE> prefix.) Also note that the message string can be a text string, or a property of any existing object.
|
---|
274 |
|
---|
275 | <P><STRONG><A NAME="back">back</A></STRONG><BR>
|
---|
276 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>back</CODE> method causes the referenced window to navigate back one URL in its history list. It's the same as if the user had pressed the 'Back' button, or the <A HREF="histo.htm" TITLE="View the History Object topic">history object</A> had been scripted to cause a jump back.
|
---|
277 |
|
---|
278 | <P><STRONG><A NAME="blur">blur</A></STRONG><BR>
|
---|
279 | This <STRONG>Netscape</STRONG> specific method can be used to forceably remove focus from a given window object. For example, suppose you have created a window (via <CODE>window.open()</CODE> code, called 'HelpWin'), the following :
|
---|
280 |
|
---|
281 | <SPAN CLASS="egcode">
|
---|
282 | <BLOCKQUOTE>
|
---|
283 | <CODE>HelpWin.<STRONG>blur()</STRONG>
|
---|
284 | </CODE>
|
---|
285 | </BLOCKQUOTE>
|
---|
286 | </SPAN>
|
---|
287 |
|
---|
288 | <P>would remove focus from the newly created window.
|
---|
289 |
|
---|
290 |
|
---|
291 | <P><STRONG><A NAME="captureEvents">captureEvents</A></STRONG><BR>
|
---|
292 | This <STRONG>Netscape</STRONG> 4.0 specific event can be used to set the a window (or <A HREF="doco.htm" TITLE="View the Document Object topic">Document</A>) object to handle single, or various events that would otherwise be handled by different document elements. For example:
|
---|
293 |
|
---|
294 | <SPAN CLASS="egcode">
|
---|
295 | <BLOCKQUOTE>
|
---|
296 | <CODE>window.captureEvents( Event.Click | Event.DblClick)
|
---|
297 | </CODE>
|
---|
298 | </BLOCKQUOTE>
|
---|
299 | </SPAN>
|
---|
300 |
|
---|
301 | <P>sets up the window to capture all click and double-click events (<CODE>onclick</CODE> and <CODE>ondblclick</CODE>). Once a window has captured events, you then need to decide what happens with them. The various options are:
|
---|
302 |
|
---|
303 | <OL>
|
---|
304 | <LI>Return true<BR>Whatever element received the event that was captured by the window event will perform its default action (i.e. an <CODE><A HREF="../Anchors/anchor.htm" TITLE="View the <A> topic"><A></A></CODE> element's default action is to navigate to the URL provided in its <CODE>HREF</CODE> attribute).
|
---|
305 | <LI>Return false<BR>The default action of the element receiving the event will not occur (e.g. the link will not navigate to the URL)
|
---|
306 | <LI>Call <A HREF="#routeEvent" TITLE="Scroll to the routeEvent method"><CODE>routeEvent</CODE></A> method<BR>This causes JavaScript to search for other event handlers for the event. For example, the <A HREF="doco.htm" TITLE="View the Document Object topic">Document Object</A> may have been trying to capture the event. Failing another object trying to capture the event, Javascript will look to the original intended target of the event, in order to decide what to do.
|
---|
307 | <LI>Call the <A HREF="#handleEvent" TITLE="Scroll to the handleEvent method">handleEvent</A> method<BR>This will force another element/object (that can handle such an event) to handle it, normally by performing its default action.
|
---|
308 | </OL>
|
---|
309 |
|
---|
310 | <P><STRONG><A NAME="clearInterval">clearInterval</A></STRONG><BR>
|
---|
311 | The <CODE>clearInterval</CODE> method cancels a corresponding <CODE>setInterval</CODE> method (described below. The syntax is :
|
---|
312 |
|
---|
313 | <SPAN CLASS="egcode">
|
---|
314 | <BLOCKQUOTE>
|
---|
315 | <CODE><STRONG>clearInterval</STRONG> (MyInterval)
|
---|
316 | </CODE>
|
---|
317 | </BLOCKQUOTE>
|
---|
318 | </SPAN>
|
---|
319 |
|
---|
320 | <P><STRONG><A NAME="clearTimeout">clearTimeout</A></STRONG><BR>
|
---|
321 | The <CODE>clearTimeout</CODE> method is used to clear a specified <CODE>setTimeout</CODE> method, by referencing it by the ID of the <CODE>setTimeout</CODE> method. For example, to clear the <CODE>setTimeout</CODE> given in the previous example, use the following code :
|
---|
322 |
|
---|
323 | <SPAN CLASS="egcode">
|
---|
324 | <BLOCKQUOTE>
|
---|
325 | <CODE>clearTimeout MyTimeOut
|
---|
326 | </CODE>
|
---|
327 | </BLOCKQUOTE>
|
---|
328 | </SPAN>
|
---|
329 |
|
---|
330 | <P><STRONG><EM>NOTE : </EM></STRONG>both the <CODE>setTimeout</CODE> and <CODE>clearTimeout</CODE> do not need the <CODE>window.</CODE> prefix, as they are methods of the top level Window object.
|
---|
331 |
|
---|
332 | <P><STRONG><A NAME="close">close</A></STRONG><BR>
|
---|
333 | The <CODE>window.close()</CODE> method closes the window specified in the <CODE>window.</CODE> prefix, which is required. Any window can be closed using this method, providing it is referenced either by its <CODE>name</CODE> property, or by <CODE>parent</CODE>, <CODE>self</CODE> or <CODE>top</CODE>. <STRONG><EM>NOTE : </EM></STRONG>From JavaScript 1.1 (as supported by Navigator 3.0 and above), the <CODE>window.close()</CODE> method only allows automatic closing of windows generated by a corresponding <CODE>window.open()</CODE> event. Attempting to close any other window will display a <CODE>confirm</CODE> dialog, prompting the user to choose whether the window is closed or not.
|
---|
334 |
|
---|
335 | <P><STRONG><A NAME="confirm">confirm</A></STRONG><BR>
|
---|
336 | Similar to the <CODE>alert</CODE> method, the <CODE>confirm</CODE> method displays a message to the user, but offers basic "OK" and "Cancel" buttons. For example, the following code displays a confirmation message and if the user chooses OK, the browser goes to the HTMLib web site. If they choose Cancel, then nothing happens.
|
---|
337 |
|
---|
338 | <SPAN CLASS="egcode">
|
---|
339 | <BLOCKQUOTE>
|
---|
340 | <CODE>function leave()<BR>
|
---|
341 | {<BR>
|
---|
342 | if (confirm("Are you sure you want to visit the HTMLib web site?"))<BR>
|
---|
343 | {location.href= "http://www.htmlib.com"}<BR>
|
---|
344 | }
|
---|
345 | </CODE>
|
---|
346 | </BLOCKQUOTE>
|
---|
347 | </SPAN>
|
---|
348 |
|
---|
349 | <P><STRONG><A NAME="disableExternalCapture">disableExternalCapture</A></STRONG><BR>
|
---|
350 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>disableExternalCapture</CODE> method allows a signed script to capture events in pages that have been loaded from different servers. For example, in a framed set-up, 'foreign' (i.e. not on the same server as the current document) pages can be loaded into a frame and a signed script can capture events on these pages. The <CODE>disableExternalCapture</CODE> method would be used to stop the capture of events from the 'foreign' pages. For more information on signed scripts, visit <A HREF="http://developer.netscape.com/library/documentation/communicator/jsguide/scripts.htm" TITLE="View Netscape Developer Web site" CLASS="external" TARGET="HTMLibExternal">Netscape DevEdge Online</A>
|
---|
351 |
|
---|
352 | <P><STRONG><A NAME="enableExternalCapture">enableExternalCapture</A></STRONG><BR>
|
---|
353 | As with the <CODE>disableExternalCapture</CODE> method described above, the <CODE>enableExternalCapture</CODE> method can be used to capture events on pages from different servers. It too requires a signed script. Visit the URL above for more details on script signing.
|
---|
354 |
|
---|
355 | <P><STRONG><A NAME="execScript">execScript</A></STRONG><BR>
|
---|
356 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>execScript</CODE> method can be used to execute script functions in a certain language.
|
---|
357 |
|
---|
358 | <P><STRONG><A NAME="find">find</A></STRONG><BR>
|
---|
359 | This <STRONG>Netscape</STRONG> 4.0 specific method invokes the 'Find' window of the browser, allowing the user to search for any text in the current document. Its effect is as if the user had chosen the 'Find' command from the Edit menu.
|
---|
360 |
|
---|
361 | <P><STRONG><A NAME="focus">focus</A></STRONG><BR>
|
---|
362 | This <STRONG>Netscape</STRONG> specific method can be used to force the focus to any window object. For example, given that there is a window named 'HelpWin', the following function snippet :
|
---|
363 |
|
---|
364 | <SPAN CLASS="egcode">
|
---|
365 | <BLOCKQUOTE>
|
---|
366 | <CODE>HelpWin.<STRONG>focus()</STRONG>
|
---|
367 | </CODE>
|
---|
368 | </BLOCKQUOTE>
|
---|
369 | </SPAN>
|
---|
370 |
|
---|
371 | <P>would pass the focus to the newly created window named HelpWin.
|
---|
372 |
|
---|
373 | <P><STRONG><A NAME="forward">forward</A></STRONG><BR>
|
---|
374 | This <STRONG>Netscape</STRONG> 4.0 specific method forces the browser to navigate forwards one URL in the history list - it's equivalent to the user pressing the 'Forward' button, or history manipulation through the <A HREF="histo.htm" TITLE="View the History Object topic">History Object</A>.
|
---|
375 |
|
---|
376 | <P><STRONG><A NAME="handleEvent">handleEvent</A></STRONG><BR>
|
---|
377 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>handleEvent</CODE> method can be used to force a different object in the document to handle an event. Note that the object in question must be able to handle the event normally for the <CODE>handleEvent</CODE> method to succeed. The <CODE>handleEvent</CODE> works with the <CODE><A HREF="#captureEvents" TITLE="Scroll to the captureEvents method">captureEvents</A></CODE>, <CODE><A HREF="#releaseEvents" TITLE="Scroll to the releaseEvents method">releaseEvents</A></CODE> and <CODE><A HREF="#routeEvent" TITLE="Scroll to the routeEvent method">routeEvent</A></CODE> methods.
|
---|
378 |
|
---|
379 | <P><STRONG><A NAME="home">home</A></STRONG><BR>
|
---|
380 | This <STRONG>Netscape</STRONG> 4.0 specific method forces the browser to navigate to the URL designated as 'Home' in the browser settings. It's identical to the user pressing the browsers 'Home' button.
|
---|
381 |
|
---|
382 | <P><STRONG><A NAME="moveBy">moveBy</A></STRONG><BR>
|
---|
383 | The <CODE>moveBy</CODE> method can be used to re-position the Navigator window, relative to its current position. For example :
|
---|
384 |
|
---|
385 | <SPAN CLASS="egcode">
|
---|
386 | <BLOCKQUOTE>
|
---|
387 | <CODE>self.<STRONG>moveBy</STRONG> (50,200)
|
---|
388 | </CODE>
|
---|
389 | </BLOCKQUOTE>
|
---|
390 | </SPAN>
|
---|
391 |
|
---|
392 | <P>would move the current window 50 pixels to the right and 200 pixels down from its current position. ('self' is used above, but any valid reference to a window object is useable). Note that it is only possible to move a <STRONG>Netscape</STRONG> browser window off-screen in a signed script. See <A HREF="http://developer.netscape.com/library/documentation/communicator/jsguide/scripts.htm" TITLE="View Netscape Developer Web site" CLASS="external" TARGET="HTMLibExternal">Netscape DevEdge Online</A> for information on script signing.
|
---|
393 |
|
---|
394 | <P><STRONG><A NAME="moveTo">moveTo</A></STRONG><BR>
|
---|
395 | The <CODE>moveTo</CODE> can be used to move the Navigator window to a specific point on the screen, by moving the top-left corner of the Navigator to the position specified :
|
---|
396 |
|
---|
397 | <SPAN CLASS="egcode">
|
---|
398 | <BLOCKQUOTE>
|
---|
399 | <CODE>self.<STRONG>moveTo</STRONG> (50,200)
|
---|
400 | </CODE>
|
---|
401 | </BLOCKQUOTE>
|
---|
402 | </SPAN>
|
---|
403 |
|
---|
404 | <P>would move the window to the position 50,200 on the users screen. Again, note that it is only possible to move a <STRONG>Netscape</STRONG> browser window off-screen in a signed script. See <A HREF="http://developer.netscape.com/library/documentation/communicator/jsguide/scripts.htm" TITLE="View Netscape Developer Web site" CLASS="external" TARGET="HTMLibExternal">Netscape DevEdge Online</A> for information on script signing.
|
---|
405 |
|
---|
406 | <P><STRONG><A NAME="navigate">navigate</A></STRONG><BR>
|
---|
407 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>navigate</CODE> method is equivalent to setting the <CODE>location.href</CODE> property to a different value, in that it causes the browser to navigate to the URL specified. For example:
|
---|
408 |
|
---|
409 | <SPAN CLASS="egcode">
|
---|
410 | <BLOCKQUOTE>
|
---|
411 | <CODE>sel.<STRONG>navigate</STRONG> ("http://www.htmlib.com")
|
---|
412 | </CODE>
|
---|
413 | </BLOCKQUOTE>
|
---|
414 | </SPAN>
|
---|
415 |
|
---|
416 | <P><STRONG><EM>Note : </EM></STRONG>For <STRONG>Internet Explorer</STRONG> 4.0, this method is only available to Visual Basic Script.
|
---|
417 |
|
---|
418 | <P><STRONG><A NAME="open">open</A></STRONG><BR>
|
---|
419 | The <CODE>open</CODE> method allows script functions to create new browser windows and load documents into them. It also allows control over the window's appearance and size. The basic syntax is :
|
---|
420 |
|
---|
421 | <SPAN CLASS="egcode">
|
---|
422 | <BLOCKQUOTE>
|
---|
423 | <CODE>Variable=window.open("URL", windowname, "window_appearance")
|
---|
424 | </CODE>
|
---|
425 | </BLOCKQUOTE>
|
---|
426 | </SPAN>
|
---|
427 |
|
---|
428 | <P>where <EM>URL</EM> is the URL of the document to be loaded into the new window, <EM>windowname</EM> is the name given to the new window (subsequently its <CODE>name</CODE> property (see above)) and <EM>window_appearance</EM> is a comma-delimited list setting the window features. The window features are boolean values (i.e. either '0' or '1', or 'no' or 'yes'). The features controllable are :
|
---|
429 |
|
---|
430 | <DL><DT><EM>toolbar</EM><DD>Specifies whether the browser's toolbar is displayed or not.
|
---|
431 | <DT><EM>location</EM><DD>Specifies whether the location bar (showing the current URL) of the browser is displayed or not.
|
---|
432 | <DT><EM>directories</EM><DD>Specifies whether the Netscape directory buttons are displayed or not.
|
---|
433 | <DT><EM>status</EM><DD>Specifies whether the browser status bar is displayed or not.
|
---|
434 | <DT><EM>menubar</EM><DD>Specifies whether the browser's menu bar is displayed or not.
|
---|
435 | <DT><EM>scrollbars</EM><DD>Specifies whether the window will allow scrollbars or not.
|
---|
436 | <DT><EM>resizable</EM><DD>Specifies whether the new window is resiz(e)able or not.
|
---|
437 | <DT><EM>width</EM>="pixels"<DD>Specifies the width of the new window.
|
---|
438 | <DT><EM>height</EM>="pixels"<DD>Specifies the height of the new window.
|
---|
439 | <DT><EM>top</EM>="pixels"<DD>Specifies the top co-ordinate to display the new window. (<STRONG>Internet Explorer</STRONG> and <STRONG>Navigator 4.0</STRONG> and above only)
|
---|
440 |
|
---|
441 | <DT><EM>left</EM>="pixels"<DD>Specifies the left co-ordinate to display the window. (<STRONG>Internet Explorer</STRONG> and <STRONG>Navigator 4.0</STRONG> and above only)
|
---|
442 |
|
---|
443 | <DT>*<EM>outerWidth</EM>*="pixels"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Specifies the outer width of the Navigator window, instead of the viewable area contained within.
|
---|
444 |
|
---|
445 | <DT>*<EM>outerHeight</EM>*="pixels"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Specifies the outer height of the Navigator window, instead of the viewable area contained within.
|
---|
446 |
|
---|
447 | <DT>*<EM>innerHeight</EM>*="pixels"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Specifies the inner height of the Navigator window - the viewable area contained within. (Note that this replaces the <CODE>height</CODE> window feature, which is maintained for backwards compatibility). To produce a new shorter narrower than 100 pixels requires a signed script.
|
---|
448 |
|
---|
449 | <DT>*<EM>innerWidth</EM>*="pixels"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Specifies the inner width of the Navigator window - the viewable area contained within. (Note that this replaces the <CODE>width</CODE> window feature, which is maintained for backwards compatibility) To produce a new window narrower than 100 pixels requires a signed script.
|
---|
450 |
|
---|
451 | <DT>*<EM>alwaysRaised</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Forces the new window to always remain above other windows, whether it has the focus or not (as certain Windows Help files are displayed - hence, it would be useful for a 'help' window helping users with web-based applications.) <STRONG><EM>Note : </EM></STRONG>This is a secure feature that can only be set in a signed script.
|
---|
452 |
|
---|
453 | <DT>*<EM>alwaysLowered</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Forces the new window to always remain below other windows, whether it has the focus or not. <STRONG><EM>Note : </EM></STRONG>This is a secure feature that can only be set in a signed script.
|
---|
454 |
|
---|
455 | <DT>*<EM>dependent</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Creates the new window as a child of the opening window, which will close when the parent window closes. Note that a dependent window does not show in the taskbar.
|
---|
456 |
|
---|
457 | <DT>*<EM>hotkeys</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) If set to true, then most of the hotkeys in the new window (if it doesn't have a menu bar are disabled, apart from the security and quit keys. (HotKeys are key combinations to perform menu operations - e.g. Ctrl+F for the File menu etc.)
|
---|
458 |
|
---|
459 | <DT>*<EM>screenX</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) screenX replaces left as the setting for the horizontal placement (in pixels) of the new window (relative to the left hand side of the screen). Note that to create a new window off screen requires a signed script.
|
---|
460 |
|
---|
461 | <DT>*<EM>screenY</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) screenY replaces top as the setting for the vertical placement (in pixels) of the new window (relative to the top of the screen). Note that to create a new window off screen requires a signed script.
|
---|
462 |
|
---|
463 | <DT>*<EM>z-lock</EM>*="yes|no||1|0"<DD>(<STRONG>Navigator 4.0</STRONG> specific) Creates a new window that never rises above other windows, even when activated. This is a secure feature that can only be set using a signed script.
|
---|
464 |
|
---|
465 | <DT>**<EM>fullscreen</EM>**="yes|no||1|0"<DD>(<STRONG>Internet Explorer</STRONG> specific) This window feature forces the newly opened window into whats known as 'kiosk mode', where the window takes the entire screen and displays with no toolbar or menubar. Care should be taken using this setting, as most users will not appreciate a new window being created that blocks their entire screen. <STRONG><EM>Note : </EM></STRONG>At the time of writing, <STRONG>Internet Explorer</STRONG> only responded to <CODE>fullscreen=1|0</CODE>.
|
---|
466 |
|
---|
467 | <DT>**<EM>channelmode</EM>**="yes|no||1|0"<DD>(<STRONG>Internet Explorer</STRONG> 4.0 specific) Creates a new window in 'channel' mode, displaying the window in theater mode, with the channel bar. <STRONG><EM>Note : </EM></STRONG>At the time of writing, <STRONG>Internet Explorer</STRONG> only responded to <CODE>channelmode=1|0</CODE>.
|
---|
468 | </DL>
|
---|
469 |
|
---|
470 | <P><STRONG><EM>NOTE : </EM></STRONG>The window features labelled above, with '*' characters are <EM>only</EM> supported in Javascript 1.2, as supported by <STRONG>Navigator 4.0</STRONG> and above. To be sure that any Javascript functions using these extended features don't throw a scripting error (or produce unwanted results), make sure to version the <CODE>LANGUAGE</CODE> attribute of the <CODE><SCRIPT></CODE> appropriately and provide version specific scripts if necessary. For more information, see <A HREF="../Scripting_Reference/javascr.htm#VERSION" TITLE="View the JavaScript topic">Versioning Javascript.</A>.
|
---|
471 |
|
---|
472 | <P><STRONG><EM>NOTE : </EM></STRONG>When using Visual Basic Script, the parenthesis characters must not be used surrounding the various <CODE>window.open</CODE> methods. I.e., the method should be used as follows under Visual Basic Script :
|
---|
473 |
|
---|
474 | <SPAN CLASS="egcode">
|
---|
475 | <BLOCKQUOTE>
|
---|
476 | <CODE>window.open URL,"window_name","window_options"
|
---|
477 | </CODE>
|
---|
478 | </BLOCKQUOTE>
|
---|
479 | </SPAN>
|
---|
480 |
|
---|
481 | <P><STRONG>Internet Explorer</STRONG> now fully supports (from 3.02) the previously <STRONG>Netscape</STRONG> specific <EM>format</EM> of the <CODE>window.open</CODE> method. For example :
|
---|
482 |
|
---|
483 | <SPAN CLASS="egcode">
|
---|
484 | <BLOCKQUOTE>
|
---|
485 | <CODE>WindowName=window.open (URL,"WindowName","window_options")
|
---|
486 | </CODE>
|
---|
487 | </BLOCKQUOTE>
|
---|
488 | </SPAN>
|
---|
489 |
|
---|
490 | <P>where <CODE>WindowName</CODE> can then be used to control the newly created window.
|
---|
491 |
|
---|
492 | <P><STRONG><EM>Note : </EM> Internet Explorer</STRONG> 4.0 supports an extra argument to the <CODE>window.open</CODE> method - the <CODE>replace</CODE> argument. For example:
|
---|
493 |
|
---|
494 | <SPAN CLASS="egcode">
|
---|
495 | <BLOCKQUOTE>
|
---|
496 | <CODE>WindowName=window.open("http://www.mysite.com/", "NewWin", "toolbar=no;...", "replace=true"
|
---|
497 | </CODE>
|
---|
498 | </BLOCKQUOTE>
|
---|
499 | </SPAN>
|
---|
500 |
|
---|
501 | <P>would cause the URL of the newly created window to over-write the URL of the creating window in the history list. Essentially, it's the same as the <CODE>replace</CODE> method of the <A HREF="loco.htm" TITLE="View the Location Object">Location Object</A>, but for multiple windows.
|
---|
502 |
|
---|
503 | <P><STRONG>The HTMLib Window Builder</STRONG><BR>
|
---|
504 | Use the 'Window Builder' below to create a new window with whatever options you like (only the options supported by <STRONG>Internet Explorer</STRONG> 4.0 are included):
|
---|
505 |
|
---|
506 | <P><STRONG><EM>Note : </EM></STRONG>Currently, <STRONG>Internet Explorer</STRONG> will allow you to create ludicrously small windows (1 x 1 pixel is even possible). So that you'll be able to actually do something with it, the Window Builder sets a minimum height and width for the new window. Also, pressing Alt&C will close the window while it has the focus.
|
---|
507 | <P>
|
---|
508 | <CENTER>
|
---|
509 | <SCRIPT LANGUAGE="VBScript">
|
---|
510 | <!--
|
---|
511 | Sub setOptFocus(optID)
|
---|
512 | Set frmFocusHandle=document.frmWindowOptions
|
---|
513 | Select Case frmFocusHandle.elements(optID).item(0).checked
|
---|
514 | Case "True" ' Yes clicked
|
---|
515 | frmFocusHandle.elements(optID).item(1).click
|
---|
516 | Case "False" ' No clicked
|
---|
517 | frmFocusHandle.elements(optID).item(0).click
|
---|
518 | End Select
|
---|
519 | End Sub
|
---|
520 | -->
|
---|
521 | </SCRIPT>
|
---|
522 | <FORM NAME="frmWindowOptions">
|
---|
523 | <TABLE BORDER="0">
|
---|
524 | <COL ALIGN="left">
|
---|
525 | <COLGROUP SPAN="2" ALIGN="center">
|
---|
526 | <TR>
|
---|
527 | <TD><STRONG>Window Feature</STRONG></TD>
|
---|
528 | <TD><STRONG>Yes</STRONG></TD>
|
---|
529 | <TD><STRONG>No</STRONG></TD>
|
---|
530 | </TR>
|
---|
531 | <TR>
|
---|
532 | <TD OnClick="setOptFocus('optTbar')" STYLE="cursor:default">Toolbar :</TD>
|
---|
533 | <TD><INPUT TYPE="radio" NAME="optTbar" VALUE="Yes"></TD>
|
---|
534 | <TD><INPUT TYPE="radio" NAME="optTbar" VALUE="No" CHECKED></TD>
|
---|
535 | </TR>
|
---|
536 | <TR>
|
---|
537 | <TD OnClick="setOptFocus('optLoc')" STYLE="cursor:default">Location :</TD>
|
---|
538 | <TD><INPUT TYPE="radio" NAME="optLoc" VALUE="Yes"></TD>
|
---|
539 | <TD><INPUT TYPE="radio" NAME="optLoc" VALUE="No" CHECKED></TD>
|
---|
540 | </TR>
|
---|
541 | <TR>
|
---|
542 | <TD OnClick="setOptFocus('optDir')" STYLE="cursor:default">Directories :</TD>
|
---|
543 | <TD><INPUT TYPE="radio" NAME="optDir" VALUE="Yes"></TD>
|
---|
544 | <TD><INPUT TYPE="radio" NAME="optDir" VALUE="No" CHECKED></TD>
|
---|
545 | </TR>
|
---|
546 | <TR>
|
---|
547 | <TD OnClick="setOptFocus('optSts')" STYLE="cursor:default">Status :</TD>
|
---|
548 | <TD><INPUT TYPE="radio" NAME="optSts" VALUE="Yes"></TD>
|
---|
549 | <TD><INPUT TYPE="radio" NAME="optSts" VALUE="No" CHECKED></TD>
|
---|
550 | </TR>
|
---|
551 | <TR>
|
---|
552 | <TD OnClick="setOptFocus('optMnu')" STYLE="cursor:default">Menubar :</TD>
|
---|
553 | <TD><INPUT TYPE="radio" NAME="optMnu" VALUE="Yes"></TD>
|
---|
554 | <TD><INPUT TYPE="radio" NAME="optMnu" VALUE="No" CHECKED></TD>
|
---|
555 | </TR>
|
---|
556 | <TR>
|
---|
557 | <TD OnClick="setOptFocus('optScr')" STYLE="cursor:default">Scrollbars :</TD>
|
---|
558 | <TD><INPUT TYPE="radio" NAME="optScr" VALUE="Yes"></TD>
|
---|
559 | <TD><INPUT TYPE="radio" NAME="optScr" VALUE="No" CHECKED></TD>
|
---|
560 | </TR>
|
---|
561 | <TR>
|
---|
562 | <TD OnClick="setOptFocus('optRsz')" STYLE="cursor:default">Resizable :</TD>
|
---|
563 | <TD><INPUT TYPE="radio" NAME="optRsz" VALUE="Yes"></TD>
|
---|
564 | <TD><INPUT TYPE="radio" NAME="optRsz" VALUE="No" CHECKED></TD>
|
---|
565 | </TR>
|
---|
566 | <TR>
|
---|
567 | <TD OnClick="setOptFocus('optFS')" STYLE="cursor:default">Fullscreen :</TD>
|
---|
568 | <TD><INPUT TYPE="radio" NAME="optFS" VALUE="Yes"></TD>
|
---|
569 | <TD><INPUT TYPE="radio" NAME="optFS" VALUE="No" CHECKED></TD>
|
---|
570 | </TR>
|
---|
571 | <TR>
|
---|
572 | <TD OnClick="setOptFocus('optChannel')" STYLE="cursor:default">ChannelMode :</TD>
|
---|
573 | <TD><INPUT TYPE="radio" NAME="optChannel" VALUE="Yes"></TD>
|
---|
574 | <TD><INPUT TYPE="radio" NAME="optChannel" VALUE="No"></TD>
|
---|
575 | </TR>
|
---|
576 | <TR>
|
---|
577 | <TD><STRONG>Width :</STRONG></TD>
|
---|
578 | <TD COLSPAN="2" ALIGN="center"><INPUT TYPE="text" NAME="txtWidth" SIZE="3" MAXLENGTH="3" VALUE="200"></TD>
|
---|
579 | </TR>
|
---|
580 | <TR>
|
---|
581 | <TD><STRONG>Height :</STRONG></TD>
|
---|
582 | <TD COLSPAN="2" ALIGN="center"><INPUT TYPE="text" NAME="txtHeight" SIZE="3" MAXLENGTH="3" VALUE="200"></TD>
|
---|
583 | </TR>
|
---|
584 | <TR>
|
---|
585 | <TD COLSPAN="3" ALIGN="center"><INPUT TYPE="button" ID="btnNewWin" VALUE="Open window" OnClick="OpenNewWindow()"></TD>
|
---|
586 | </TR>
|
---|
587 | </TABLE>
|
---|
588 | <TABLE>
|
---|
589 | <TR>
|
---|
590 | <TD><TEXTAREA ROWS="2" COLS="40" ID="txtEgCode" STYLE="font:8pt Arial">The code used will appear here...</TEXTAREA></TD>
|
---|
591 | </TR>
|
---|
592 | </TABLE>
|
---|
593 | </FORM>
|
---|
594 | </CENTER>
|
---|
595 |
|
---|
596 | <SCRIPT LANGUAGE="VBScript">
|
---|
597 | <!--
|
---|
598 | Sub OpenNewWindow()
|
---|
599 | Set frmHandle=document.frmWindowOptions
|
---|
600 | Select case frmHandle.elements("optTbar").item(0).checked
|
---|
601 | Case "True"
|
---|
602 | msgTbar="toolbar=1, "
|
---|
603 | Case "False"
|
---|
604 | msgTbar=""
|
---|
605 | End Select
|
---|
606 | Select case frmHandle.elements("optLoc").item(0).checked
|
---|
607 | Case "True"
|
---|
608 | msgLoc="location=1, "
|
---|
609 | Case "False"
|
---|
610 | msgLoc=""
|
---|
611 | End Select
|
---|
612 | Select case frmHandle.elements("optDir").item(0).checked
|
---|
613 | Case "True"
|
---|
614 | msgDir="directories=1, "
|
---|
615 | Case "False"
|
---|
616 | msgDir=""
|
---|
617 | End Select
|
---|
618 | Select case frmHandle.elements("optSts").item(0).checked
|
---|
619 | Case "True"
|
---|
620 | msgSts="status=1, "
|
---|
621 | Case "False"
|
---|
622 | msgSts=""
|
---|
623 | End Select
|
---|
624 | Select case frmHandle.elements("optMnu").item(0).checked
|
---|
625 | Case "True"
|
---|
626 | msgMnu="menubar=1, "
|
---|
627 | Case "False"
|
---|
628 | msgMnu=""
|
---|
629 | End Select
|
---|
630 | Select case frmHandle.elements("optScr").item(0).checked
|
---|
631 | Case "True"
|
---|
632 | msgScr="scrollbars=1, "
|
---|
633 | Case "False"
|
---|
634 | msgScr=""
|
---|
635 | End Select
|
---|
636 | Select case frmHandle.elements("optRsz").item(0).checked
|
---|
637 | Case "True"
|
---|
638 | msgRsz="resizable=1, "
|
---|
639 | Case "False"
|
---|
640 | msgRsz=""
|
---|
641 | End Select
|
---|
642 | Select case frmHandle.elements("optFS").item(0).checked
|
---|
643 | Case "True"
|
---|
644 | msgFS="fullscreen=1, "
|
---|
645 | Case "False"
|
---|
646 | msgFS=""
|
---|
647 | End Select
|
---|
648 | Select case frmHandle.elements("optChannel").item(0).checked
|
---|
649 | Case "True"
|
---|
650 | msgCh="channelmode=1, "
|
---|
651 | bIsChannel=True
|
---|
652 | Case "False"
|
---|
653 | msgCh=""
|
---|
654 | End Select
|
---|
655 | if frmHandle.elements("txtWidth").value < "200" then frmHandle.elements("txtWidth").value="200"
|
---|
656 | if frmHandle.elements("txtHeight").value < "200" then frmHandle.elements("txtHeight").value="200"
|
---|
657 | msgWidth = "width=" & frmHandle.elements("txtWidth").value & ", "
|
---|
658 | msgHeight = "height=" & frmHandle.elements("txtHeight").value
|
---|
659 | if bIsChannel=True then
|
---|
660 | msg = Chr(34) & "d, " & msgLoc & msgTbar & msgDir & msgSts & msgMnu & msgScr & msgRsz & msgFS & msgCh & Chr(34)
|
---|
661 | else
|
---|
662 | msg = Chr(34) & "d, " & msgLoc & msgTbar & msgDir & msgSts & msgMnu & msgScr & msgRsz & msgFS & msgCh & msgWidth & msgHeight & Chr(34)
|
---|
663 | End If
|
---|
664 | window.open "windop.htm", "NewWin", msg
|
---|
665 | egmsg = Chr(34) & mid(msg,5,len(msg)) ' Remove the 'd, ', add "
|
---|
666 | document.frmWindowOptions.elements("txtEgCode").value = "window.open " & Chr(34) & "windop.htm" & CHr(34) & ", " & Chr(34) & "NewWin" & Chr(34) & ", " & egmsg
|
---|
667 | End Sub
|
---|
668 | -->
|
---|
669 | </SCRIPT>
|
---|
670 |
|
---|
671 |
|
---|
672 | <P><STRONG><A NAME="tlnote">A note</A> about the <EM>top</EM> and <EM>left</EM> window options</STRONG><BR>
|
---|
673 | <CODE>top</CODE> and <CODE>left</CODE> should be used with care when positioning new windows exactly (i.e. by pixel measurements) because you can not be sure of the users screen resolution (although <STRONG>Navigator 4.0</STRONG> now provides screen resizing and moving methods (see below)). Also, be aware of a current limitation in the <STRONG>Internet Explorer</STRONG> 3.01 support of these window settings. If the document calling the <CODE>window.open</CODE> method is displayed singularly (i.e. not part of a frameset), then <CODE>top</CODE> and <CODE>left</CODE> behave as expected and can be used to set the position of the new window, (in pixel units) on the screen.<BR>
|
---|
674 | If the document calling the <CODE>window.open</CODE> method is a framed document (i.e. displayed in a frame), however, then it starts to get a little complicated. For some as yet unknown reason the <CODE>top</CODE> and <CODE>left</CODE> co-ordinates should be reversed, to display the newly created window in the right position. For example if the following code is executed in a non-framed document,
|
---|
675 |
|
---|
676 | <SPAN CLASS="egcode">
|
---|
677 | <BLOCKQUOTE>
|
---|
678 | <CODE>NewWin=window.open(URL,name,"left=640,top=480");
|
---|
679 | </CODE>
|
---|
680 | </BLOCKQUOTE>
|
---|
681 | </SPAN>
|
---|
682 |
|
---|
683 | <P>then the new window would be created at a position x=640 pixels and y=480 pixels. However, if the same code was executed from a framed document, then the new window would be created and displayed at x=480 y=640 pixels. For the same code to work, displaying the window in the same position, called from a framed document, the code would need to be :
|
---|
684 |
|
---|
685 | <SPAN CLASS="egcode">
|
---|
686 | <BLOCKQUOTE>
|
---|
687 | <CODE>NewWin=window.open(URL,name,"left=480,top=640");
|
---|
688 | </CODE>
|
---|
689 | </BLOCKQUOTE>
|
---|
690 | </SPAN>
|
---|
691 |
|
---|
692 | <P>Just to add to the confusion, <STRONG>Internet Explorer</STRONG> 3.02 seems to have permanently reversed the <CODE>top</CODE> and <CODE>left</CODE> settings (so that calling <CODE>...left=<EM>x1</EM>, top=<EM>y1</EM></CODE> actually places the new window at a position x=<CODE><EM>y1</EM></CODE>, y=<CODE><EM>x1</EM></CODE> pixels), regardless of whether the document utilising the <CODE>window.open</CODE> method is framed or single. Support of these two method attributes is basically a legacy of the previously supported 'Explorer' object, which was supported in the Windows 95/NT4 v3.01 of <STRONG>Internet Explorer</STRONG>, but removed from v3.02 for security reasons.
|
---|
693 |
|
---|
694 | <P><STRONG><EM>NOTE : </EM></STRONG> The <CODE>top</CODE> and <CODE>left</CODE> attributes are not officially documented as being supported by <STRONG>Internet Explorer</STRONG>, so should be used with care as their support may possibly change without notice.
|
---|
695 |
|
---|
696 | <P><STRONG><A NAME="print">print</A></STRONG><BR>
|
---|
697 | This <STRONG>Netscape</STRONG> 4.0 specific method prints the document in the referenced window or frame, using the default printing properties for the browser. Its effect is as if the user had pressed the 'Print' button on the browser. It would be courteous to give users an option to print documents, rather than automatically printing them from a script function.
|
---|
698 |
|
---|
699 | <P><STRONG><A NAME="prompt">prompt</A></STRONG><BR>
|
---|
700 | Again, like the above two methods, the <CODE>prompt</CODE> method allows you to present the user with a dialog allowing them to enter values (like Visual Basic Script's <CODE>InputBox</CODE> method). The method is called, defining a default value in the input box. For example, the following code asks the user to enter a year, giving 1996 as the default value.
|
---|
701 |
|
---|
702 | <SPAN CLASS="egcode">
|
---|
703 | <BLOCKQUOTE>
|
---|
704 | <CODE>prompt("Enter a year", 1996)
|
---|
705 | </CODE>
|
---|
706 | </BLOCKQUOTE>
|
---|
707 | </SPAN>
|
---|
708 |
|
---|
709 | <P ALIGN="center">
|
---|
710 |
|
---|
711 | <P><STRONG><A NAME="releaseEvents">releaseEvents</A></STRONG><BR>
|
---|
712 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>releaseEvents</CODE> method can be used to release events that had previously been captured using the <A HREF="#captureEvents" TITLE="Scroll to the captureEvents method"><CODE>captureEvents</CODE></A> method. The syntax for releasing single, or multiple events is the same as for the <CODE>captureEvents</CODE> method.
|
---|
713 |
|
---|
714 | <P><STRONG><A NAME="resizeBy">resizeBy</A></STRONG><BR>
|
---|
715 | As you'll probably have guessed, the <CODE>resizeBy</CODE> method resizes the window from its current size by the amounts specified. For example :
|
---|
716 |
|
---|
717 | <SPAN CLASS="egcode">
|
---|
718 | <BLOCKQUOTE>
|
---|
719 | <CODE>self.<STRONG>resizeBy</STRONG> (50,200)
|
---|
720 | </CODE>
|
---|
721 | </BLOCKQUOTE>
|
---|
722 | </SPAN>
|
---|
723 |
|
---|
724 | <P>would move the bottom right hand corner of the navigator window 50 pixels to the right and 200 pixels down, creating a larger window. Note that to resize a window to less than 100x100 pixels requires a signed script.
|
---|
725 |
|
---|
726 | <P><STRONG><A NAME="resizeTo">resizeTo</A></STRONG><BR>
|
---|
727 | Like the <CODE>moveTo</CODE> method above, the <CODE>resizeTo</CODE> method can be used to resize the window to a specific size. For example :
|
---|
728 |
|
---|
729 | <SPAN CLASS="egcode">
|
---|
730 | <BLOCKQUOTE>
|
---|
731 | <CODE>self.<STRONG>resizeTo</STRONG> (640,480)
|
---|
732 | </CODE>
|
---|
733 | </BLOCKQUOTE>
|
---|
734 | </SPAN>
|
---|
735 |
|
---|
736 | <P>would resize the window to 640 by 480 pixels. Again, to resize a window to less than 100x100 pixels requires a signed script.
|
---|
737 |
|
---|
738 | <P>Be aware that you can not guarantee the viewers screen resolution, so regardless of the imposed restrictions, use these methods with caution. The sensible option would be to always use a <CODE>moveTo</CODE> method to set the window at the top-left corner of the users screen before performing any resizing methods, to ensure the entire viewing area is visible. Also limiting the maximum size of sites requiring this functionality to 640x480 pixels would also be sensible.
|
---|
739 |
|
---|
740 | <P><STRONG><A NAME="routeEvent">routeEvent</A></STRONG><BR>
|
---|
741 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>routeEvent</CODE> method can be used to route an event that has been previously captured using the <A HREF="#captureEvents" TITLE="Scroll to the captureEvents method"><CODE>captureEvents</CODE></A> method. It uses the following syntax:
|
---|
742 |
|
---|
743 | <SPAN CLASS="egcode">
|
---|
744 | <BLOCKQUOTE>
|
---|
745 | <CODE>objectReference.routeEvent(eventType)
|
---|
746 | </CODE>
|
---|
747 | </BLOCKQUOTE>
|
---|
748 | </SPAN>
|
---|
749 |
|
---|
750 | <P>for example:
|
---|
751 |
|
---|
752 | <SPAN CLASS="egcode">
|
---|
753 | <BLOCKQUOTE>
|
---|
754 | <CODE>document.BigLink.routeEvent(event.click)
|
---|
755 | </CODE>
|
---|
756 | </BLOCKQUOTE>
|
---|
757 | </SPAN>
|
---|
758 |
|
---|
759 | <P>would pass click events to the element whose <CODE>ID</CODE> property is <CODE>BigLink</CODE>
|
---|
760 |
|
---|
761 | <P><STRONG><A NAME="scroll">scroll</A></STRONG><BR>
|
---|
762 | This specific method can be used to automatically move the user to any point in the current window. It is similar to mid page links, using <CODE><A HREF="#..."></CODE> constructs, except it moves the user to a position of pixel values, rather than links. For example :
|
---|
763 |
|
---|
764 | <SPAN CLASS="egcode">
|
---|
765 | <BLOCKQUOTE>
|
---|
766 | <CODE>HelpWin.<STRONG>scroll(200,300)</STRONG>
|
---|
767 | </CODE>
|
---|
768 | </BLOCKQUOTE>
|
---|
769 | </SPAN>
|
---|
770 |
|
---|
771 | <P>would scroll the user to the position 200,300 (in pixels). The number sequence is <EM>x-coordinate</EM>, <EM>y-coordinate</EM>.
|
---|
772 |
|
---|
773 | <P><STRONG><A NAME="scrollBy">scrollBy</A></STRONG><BR>
|
---|
774 | As with the other <CODE>*By</CODE> methods, the <CODE>scrollBy</CODE> scrolls the viewing area of the window by the amounts specified in the values. For example :
|
---|
775 |
|
---|
776 | <SPAN CLASS="egcode">
|
---|
777 | <BLOCKQUOTE>
|
---|
778 | <CODE>self.<STRONG>scrollBy</STRONG> (50,100)
|
---|
779 | </CODE>
|
---|
780 | </BLOCKQUOTE>
|
---|
781 | </SPAN>
|
---|
782 |
|
---|
783 | <P>would scroll the viewing window 50 pixels to the left and 100 pixels down. Scrolling to the right would only be effective is there is content currently off the screen (for example, you may have layers currently off-screen, or very wide images).
|
---|
784 |
|
---|
785 |
|
---|
786 | <P><STRONG><A NAME="scrollTo">scrollTo</A></STRONG><BR>
|
---|
787 | This method scrolls the viewing window to an exact pixel position, given by the values. For example :
|
---|
788 |
|
---|
789 | <SPAN CLASS="egcode">
|
---|
790 | <BLOCKQUOTE>
|
---|
791 | <CODE>self.<STRONG>scrollTo</STRONG> (100,300)
|
---|
792 | </CODE>
|
---|
793 | </BLOCKQUOTE>
|
---|
794 | </SPAN>
|
---|
795 |
|
---|
796 | <P>scrolls to the point 100 pixels to the right and 300 pixels down.
|
---|
797 | <P><STRONG><EM>Note : </EM></STRONG> scrollTo extends the <CODE>scroll</CODE> method (see above), which is still supported in Navigator 4.0 and above for backwards compatibility.
|
---|
798 |
|
---|
799 | <P><STRONG><A NAME="setInterval">setInterval</A></STRONG><BR>
|
---|
800 | The <CODE>setInterval</CODE> method can be used to either call a Javascript function, or evaluate an expression, after a specified time interval (in millisecond) has expired. For example :
|
---|
801 |
|
---|
802 | <SPAN CLASS="egcode">
|
---|
803 | <BLOCKQUOTE>
|
---|
804 | <CODE><STRONG>setInterval</STRONG>=MyInterval (startanim(),1000,20,100)</CODE>
|
---|
805 | </BLOCKQUOTE>
|
---|
806 | </SPAN>
|
---|
807 |
|
---|
808 | <P>would execute the function <CODE>startanim()</CODE>, after 1 second has elapsed (1000 milliseconds), passing it 20 and 100 as arguments to the function. Any number of arguments can be passed in the <CODE>setInterval</CODE> method (i.e. as many as are required by the function). The <CODE>setInterval</CODE> method will repeatedly call the referenced function, or expression, until the user leaves the document that contains the script. This is essentially the only difference between it and the <CODE>setTimeout</CODE> method, which is only executed once, after the specified time interval.
|
---|
809 |
|
---|
810 |
|
---|
811 | <P><STRONG><A NAME="setTimeout">setTimeout</A></STRONG><BR>
|
---|
812 | The <CODE>setTimeout</CODE> method can be used to execute a script function, or access any existing object property or method, after a specified time interval. For example, the following code section would execute the script function <CODE>TooMuchTime()</CODE> after 5 seconds :
|
---|
813 |
|
---|
814 | <SPAN CLASS="egcode">
|
---|
815 | <BLOCKQUOTE>
|
---|
816 | <CODE>MyTimeOut=setTimeout ("TooMuchTime()", 5000)
|
---|
817 | </CODE>
|
---|
818 | </BLOCKQUOTE>
|
---|
819 | </SPAN>
|
---|
820 |
|
---|
821 | <P>The time interval is always specified in milliseconds.<BR>
|
---|
822 | In Javascript 1.2 (as supported by Navigator 4.0 and above), the <CODE>setTimeout</CODE> method can be used to evaluate an expression, as well as calling functions. Note that this will require using <CODE>LANGUAGE="Javascript1.2"</CODE> in the <A HREF="../Scripting_Reference/javascr.htm"><CODE><SCRIPT></CODE></A> element, so as to prevent older browsers throwing a scripting error, or not functioning as expected.
|
---|
823 |
|
---|
824 | <P><STRONG><A NAME="showHelp">showHelp</A></STRONG><BR>
|
---|
825 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>showHelp</CODE> method creates an instance of the <A HREF="http://msdn.microsoft.com/workshop/author/htmlhelp/" TARGET="HTMLibExternal" CLASS="external" TITLE="Visit the Microsoft HtmlHelp site">HtmlHelp</A> window, passing it the URL given as an argument to the method. For example:
|
---|
826 |
|
---|
827 | <SPAN CLASS="egcode">
|
---|
828 | <BLOCKQUOTE>
|
---|
829 | <CODE>self.<STRONG>showHelp</STRONG> "help.htm"
|
---|
830 | </CODE>
|
---|
831 | </BLOCKQUOTE>
|
---|
832 | </SPAN>
|
---|
833 |
|
---|
834 | <P>would load help.htm into a newly created HtmlHelp window. Note that HtmlHelp windows are children of the window that creates them, so the HtmlHelp window will close down when the window that created it is closed
|
---|
835 |
|
---|
836 | <P>Pressing this button demonstrates the <CODE>showHelp</CODE> method :
|
---|
837 |
|
---|
838 | <P ALIGN="center">
|
---|
839 | <INPUT TYPE="button" OnClick="self.showHelp 'scrhelp.htm','HTMLib example'" VALUE="showHelp">
|
---|
840 |
|
---|
841 | <P><STRONG><A NAME="showModalDialog">showModalDialog</A></STRONG><BR>
|
---|
842 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>showModalDialog</CODE> method can be used to create a modal dialog window. This is a special window that does not release the focus back to the window that created it until it is closed, preventing the user from switching back to the main document until they have satisfied the requirements of the modal dialog window (or closed it).
|
---|
843 |
|
---|
844 | <P>The <CODE>showModalDialog</CODE> method is:
|
---|
845 |
|
---|
846 | <BLOCKQUOTE><EM>Variant</EM> = object.<STRONG>showModalDialog</STRONG><EM>(URL [, arguments [, features]])</EM>
|
---|
847 | </BLOCKQUOTE>
|
---|
848 |
|
---|
849 | <P>where:
|
---|
850 |
|
---|
851 | <DL>
|
---|
852 | <DT>URL<DD> represents the location of the file to open in the dialog.
|
---|
853 | <DT>arguments<DD> can be a string value specifying some arguments for the opening window. I.e. initialisation values etc.
|
---|
854 | <DT>features<DD> allows setting of the decoration for the dialog, covering the following:
|
---|
855 | <TABLE BORDER="0" WIDTH="85%">
|
---|
856 | <TR>
|
---|
857 | <TD NOWRAP><STRONG>feature name</STRONG></TD>
|
---|
858 | <TD><STRONG>Description</STRONG></TD>
|
---|
859 | </TR>
|
---|
860 | <TR>
|
---|
861 | <TD>dialogWidth</TD>
|
---|
862 | <TD>Initial dialog width, in pixels</TD>
|
---|
863 | </TR>
|
---|
864 | <TR>
|
---|
865 | <TD>dialogHeight</TD>
|
---|
866 | <TD>Initial dialog height, in pixels</TD>
|
---|
867 | </TR>
|
---|
868 | <TR>
|
---|
869 | <TD>dialogTop</TD>
|
---|
870 | <TD>Initial vertical offset, in pixels</TD>
|
---|
871 | </TR>
|
---|
872 | <TR>
|
---|
873 | <TD>dialogLeft</TD>
|
---|
874 | <TD>Initial horizontal offset, in pixels</TD>
|
---|
875 | </TR>
|
---|
876 | <TR>
|
---|
877 | <TD>center</TD>
|
---|
878 | <TD>A boolean (yes|no|0|1) value describing whether to automatically centre the dialog in the screen</TD>
|
---|
879 | </TR>
|
---|
880 | <TR>
|
---|
881 | <TD>font</TD>
|
---|
882 | <TD>Specifies font settings, according to the font Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
883 | </TR>
|
---|
884 | <TR>
|
---|
885 | <TD>font-family</TD>
|
---|
886 | <TD>Specifies font family, according to the font-family Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
887 | </TR>
|
---|
888 | <TR>
|
---|
889 | <TD>font-size</TD>
|
---|
890 | <TD>Specifies font size, according to the font-size Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
891 | </TR>
|
---|
892 | <TR>
|
---|
893 | <TD>font-weight</TD>
|
---|
894 | <TD>Specifies font weight (boldness), according to the font-weight Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
895 | </TR>
|
---|
896 | <TR>
|
---|
897 | <TD>font-style</TD>
|
---|
898 | <TD>Specifies font style settings, according to the font-style Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
899 | </TR>
|
---|
900 | <TR>
|
---|
901 | <TD>font-variant</TD>
|
---|
902 | <TD>Specifies font variant, according to the font-variant Style Sheet property (see <A HREF="../Style_Sheets/fontpro.htm" TITLE="View the Font properties topic">Font properties</A> for more information.</TD>
|
---|
903 | </TR>
|
---|
904 | <TR>
|
---|
905 | <TD>border</TD>
|
---|
906 | <TD>Specifies the border width (thick|think)</TD>
|
---|
907 | </TR>
|
---|
908 | <TR>
|
---|
909 | <TD>help</TD>
|
---|
910 | <TD>A boolean value setting whether to show the '?' button to the title bar</TD>
|
---|
911 | </TR>
|
---|
912 | <TR>
|
---|
913 | <TD>minimize</TD>
|
---|
914 | <TD>A boolean value setting whether to show the minimise button to the title bar</TD>
|
---|
915 | </TR>
|
---|
916 | <TR>
|
---|
917 | <TD>maximize</TD>
|
---|
918 | <TD>A boolean value setting whether to show the maximise button to the title bar</TD>
|
---|
919 | </TR>
|
---|
920 | </TABLE>
|
---|
921 | </DL>
|
---|
922 |
|
---|
923 | <P ALIGN="center"><INPUT TYPE="button" ID="btnSMD" VALUE="showModalDialog() example">
|
---|
924 |
|
---|
925 | <SCRIPT LANGUAGE="VBScript">
|
---|
926 | <!--
|
---|
927 | Sub btnSMD_OnClick
|
---|
928 | self.showModalDialog "smdhelp.htm",null,"status:no;center:yes;help:no;minimize:no;maximize:no;border:thin;statusbar:no;dialogWidth:300px;dialogHeight:225px"
|
---|
929 | End Sub
|
---|
930 | -->
|
---|
931 | </SCRIPT>
|
---|
932 | <P><STRONG><EM>Note : </EM></STRONG>At the time of writing, <STRONG>Internet Explorer</STRONG> 4.0 modal dialogs would lose their 'modality' if the file loaded caused a scripting error.
|
---|
933 |
|
---|
934 | <P><STRONG><A NAME="stop">stop</A></STRONG><BR>
|
---|
935 | This <STRONG>Netscape</STRONG> 4.0 specific method causes downloading of the page to stop, as if the user had pressed the 'Stop' button on the browser.
|
---|
936 |
|
---|
937 | <P><STRONG>A note about window references for the positioning/moving methods</STRONG><BR>
|
---|
938 | For the <CODE>moveBy</CODE>, <CODE>moveTo</CODE>, <CODE>resizeBy</CODE> and <CODE>resizeTo</CODE> methods, the whole navigator window is moved or resized. This means that if the methods are invoked in a framed document, then the entire Navigator window is altered, <EM>regardless</EM> of the window reference (providing that it is valid). I.e. using 'top', 'self' and 'parent', or referencing any framed document currently in the same Navigator display window all have the same effect. Single documents, or separate windows (created from links, or the <CODE>open</CODE> method) can be referenced by their name.<BR>
|
---|
939 | For the <CODE>scrollBy</CODE> and <CODE>scrollTo</CODE> methods, all windows (framed or otherwise) can be manipulated by using a valid reference. However, if the window referenced doesn't contain sufficient content for scrollbars to be necessary, then both these methods will do nothing.
|
---|
940 |
|
---|
941 | <P><STRONG><A NAME="events">Window Events</A></STRONG><BR>
|
---|
942 | Internet Explorer 4.0 only supports the <SPAN CLASS="attr">onHelp</SPAN> <A HREF="../Dynamic_HTML/dhtmle.htm" TITLE="View the Standard Dynamic HTML events topic">Standard Dynamic HTML events</A>. <STRONG>Netscape</STRONG> supports some of these events for the Window Object. See the standard Dynamic HTML events for details. Additionally, the following events are supported:
|
---|
943 |
|
---|
944 | <P><STRONG><A NAME="OnBeforeUnload">OnBeforeUnload</A></STRONG><BR>
|
---|
945 | This <STRONG>Internet Explorer</STRONG> 4.0 specific event fired <EM>before</EM> the <CODE>onunload</CODE> event (see below). It has been added with <A HREF="../Dynamic_HTML/ddata.htm" TITLE="View the Data Binding topic">Data Binding</A>, to allow data to be updated prior to the page being unloaded.
|
---|
946 |
|
---|
947 | <P><STRONG><A NAME="OnBlur">OnBlur</A></STRONG><BR>
|
---|
948 | This event handler can be used in <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> and <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> elements, as well as for the Window object. It is fired whenever the user removes focus from the referenced window object. For extra details, see the <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> and <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> topics.
|
---|
949 |
|
---|
950 | <P><STRONG><A NAME="OnDragDrop">OnDragDrop</A></STRONG><BR>
|
---|
951 | The <STRONG>Netscape</STRONG> 4.0 specific <CODE>OnDragDrop</CODE> event for the window object occurs when the user attempts to drag and drop an object (typically an HTML document) onto the current window. Using various <A HREF="evento.htm" TITLE="View the Event Object topic">Event Object</A> for <STRONG>Netscape</STRONG>, it's possible to perform script functions whenever the user drops an object on the navigator window.
|
---|
952 |
|
---|
953 | <P><STRONG><A NAME="OnError">OnError</A></STRONG><BR>
|
---|
954 | This event handler can be used in <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> and <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> elements, as well as the more general Window object and is fired when an error occurs for the window, for example, the document doesn't load, or a script error occurs.
|
---|
955 |
|
---|
956 | <P><STRONG><A NAME="OnFocus">OnFocus</A></STRONG><BR>
|
---|
957 | This event handler can be used in <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> and <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> elements as well as the general window object and is fired whenever the user focuses on the referenced window. For exact details, see those topics.
|
---|
958 |
|
---|
959 | <STRONG><A NAME="OnLoad">OnLoad</A></STRONG><BR>
|
---|
960 | The <CODE>OnLoad</CODE> event can be used in window objects. It is generally used in the <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> element, or <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> elements (<STRONG>Netscape</STRONG> only) and executes functions when the document (framed or normal) has finished loading. For information about this event, see the relevant element topics.
|
---|
961 |
|
---|
962 | <P><STRONG><A NAME="OnMove">OnMove</A></STRONG><BR>
|
---|
963 | This <STRONG>Netscape</STRONG> 4.0 specific event is fired whenever a <CODE>MoveBy</CODE> or <CODE>MoveTo</CODE> method (see above) is used on any valid Window Object, or the user moves the referenced window.
|
---|
964 |
|
---|
965 | <P><STRONG><A NAME="OnResize">OnResize</A></STRONG><BR>
|
---|
966 | This <STRONG>Internet Explorer</STRONG> 4.0 specific event is fired whenever the user resizes the referenced window. Content that is sized according to the users viewing window could be resized when this event fires for example.
|
---|
967 |
|
---|
968 | <P><STRONG><A NAME="OnScroll">OnScroll</A></STRONG><BR>
|
---|
969 | The <STRONG>Internet Explorer</STRONG> 4.0 specific <CODE>onScroll</CODE> event is fired whenever the user scrolls in the referenced window.
|
---|
970 |
|
---|
971 | <P><STRONG><A NAME="OnUnLoad">OnUnLoad</A></STRONG><BR>
|
---|
972 | The opposite of the above event, the <CODE>OnUnLoad</CODE> event is used to execute script functions when the user exits a window object (a frame window, or a normal window). It is also used only in the <CODE><A HREF="../Document_Structure_Elements/body.htm" TITLE="View the <BODY> topic"><BODY></A></CODE> and <CODE><A HREF="../Frames/fset.htm" TITLE="View the <FRAMESET> topic"><FRAMESET></A></CODE> elements (supported in both elements, by both browsers). For details, see those topics.
|
---|
973 |
|
---|
974 |
|
---|
975 | <P>
|
---|
976 |
|
---|
977 | <P ALIGN="right" CLASS="copyright">© 1995-1998, Stephen Le Hunte</P>
|
---|
978 | </BODY>
|
---|
979 | </HTML>
|
---|