📄 ref_m-q.htm
字号:
<H3>Description</H3>
<P>Use the navigator object to determine which version of the Navigator your users have.
<H3>Properties</H3>
<LI><A HREF="ref_a-c.htm#appCodeName_property" appCodeName_property">appCodeName</A> specifies the code name of the browser
<LI><A HREF="ref_a-c.htm#appName_property" appName_property">appName</A> specifies the name of the browser
<LI><A HREF="ref_a-c.htm#appVersion_property" appVersion_property">appVersion</A> specifies version information for the Navigator
<LI><A HREF="ref_t-z.htm#userAgent_property" userAgent_property">userAgent</A> specifies the user-agent header
<H3>Methods</H3>
<LI>None.
<H3>Event handlers</H3>
<LI>None.
<H3>例子</H3>
<P>See the 例子 for the individual properties.
<H3>相关</H3>
<LI><A HREF="ref_h-l.htm#link_object" link_object">link</A> object
<LI><A HREF="ref_a-c.htm#anchor_object" anchor_object">anchors</A> object
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onBlur_event"><H2>onBlur event handler</H2></A>
<P>A blur event occurs when a select, text, or textarea field on a form loses focus. The onBlur event handler executes JavaScript code when a blur event occurs.
<P>See the relevant objects for the onBlur 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_s-s.htm#select_object" select_object">select</A>, <A HREF="ref_t-z.htm#text_object" text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A>
<H3>例子</H3>
<P>In the following example, <I>userName</I> is a required text field. When a user attempts to leave the field, the onBlur event handler calls the required() function to confirm that <I>userName</I> has a legal value.
<PRE><INPUT TYPE="text" VALUE="" NAME="userName" onBlur="required(this.value)"></PRE>
<H3>相关</H3>
<LI> <A HREF="ref_m-q.htm#onChange_event" onChange_event">onChange</A> , <A HREF="ref_m-q.htm#onFocus_event" onFocus_event">onFocus</A> event handlers
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onChange_event"><H2>onChange event handler</H2></A>
<P>A change event occurs when a select, text, or textarea field loses focus and its value has been modified. The onChange event handler executes JavaScript code when a change event occurs.
<P>Use the onChange event handler to validate data after it is modified by a user.
<P>See the relevant objects for the onChange 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_s-s.htm#select_object" select_object">select</A>, <A HREF="ref_t-z.htm#text_object" text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A>
<H3>例子</H3>
<P>In the following example, <I>userName</I> is a text field. When a user attempts to leave the field, the onBlur event handler calls the checkValue() function to confirm that <I>userName</I> has a legal value.
<PRE><INPUT TYPE="text" VALUE="" NAME="userName" onBlur="checkValue(this.value)"></PRE>
<H3>相关</H3>
<LI> <A HREF="ref_m-q.htm#onBlur_event" onBlur_event">onBlur</A> , <A HREF="ref_m-q.htm#onFocus_event" onFocus_event">onFocus</A> event handlers
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onClick_event"><H2>onClick event handler</H2></A>
<P>
A click event occurs when an object on a form is clicked. The onClick event handler executes JavaScript code when a click event occurs.
<P>See the relevant objects for the onClick 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_a-c.htm#button_object" button_object">button</A>, <A HREF="ref_a-c.htm#checkbox_object" checkbox_object">checkbox</A>, <A HREF="ref_r-r.htm#radio_object" radio_object">radio</A>, <A HREF="ref_h-l.htm#link_object" link_object">link</A>, <A HREF="ref_r-r.htm#reset_object" reset_object">reset</A>, <A HREF="ref_s-s.htm#submit_object" submit_object">submit</A>
<H3>例子</H3>
<P>
For example, suppose you have created a JavaScript function called compute(). You can execute the compute() function when the user clicks a button by calling the function in the onClick event handler, as follows:
<PRE><INPUT TYPE="button" VALUE="Calculate" onClick="compute(this.form)"></PRE>
<P>In the above example, the keyword <I>this</I> refers to the current object; in this case, the Calculate button. The construct <I>this.form</I> refers to the form containing the button.
<P>For another example, suppose you have created a JavaScript function called pickRandomURL() that lets you select a URL at random. You can use the onClick event handler of a link to specify a value for the HREF attribute of the <A> tag dynamically, as shown in the following example:
<XMP><A HREF=""
onClick="this.href=pickRandomURL()"
onMouseOver="window.status='Pick a random URL'; return true">
Go!</A></XMP>
<P>In the above example, the onMouseOver event handler specifies a custom message for the Navigator status bar when the user places the mouse pointer over the Go! anchor. As this example shows, you must return true to set the window.status property in the onMouseOver event handler.
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onFocus_event"><H2>onFocus event handler</H2></A>
<P>
A focus event occurs when a field receives input focus by tabbing with the keyboard or clicking with the mouse. Selecting within a field results in a select event, not a focus event. The onFocus event handler executes JavaScript code when a focus event occurs.
<P>See the relevant objects for the onFocus 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_s-s.htm#select_object" select_object">select</A>, <A HREF="ref_t-z.htm#text_object" text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A>
<H3>例子</H3>
<P>The following example uses an onFocus handler in the <I>valueField</I> textarea object to call the valueCheck() function.
<PRE><INPUT TYPE="textarea" VALUE="" NAME="valueField" onFocus="valueCheck()"></PRE>
<H3>相关</H3>
<LI> <A HREF="ref_m-q.htm#onBlur_event" onBlur_event">onBlur</A> , <A HREF="ref_m-q.htm#onChange_event" onChange_event">onChange</A> event handlers
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onLoad_event"><H2>onLoad event handler</H2></A>
<P>A load event occurs when Navigator finishes loading a window or all frames within a <FRAMESET>. The onLoad event handler executes JavaScript code when a load event occurs.
<P>Use the onLoad event handler within either the <BODY> or the <FRAMESET> tag, for example, <TT><BODY onLoad="..."></TT>.
<P>In a <FRAMESET> and <FRAME> relationship, an onLoad event within a frame (placed in the <BODY> tag) occurs before an onLoad event within the <FRAMESET> (placed in the <FRAMESET> tag).
<H3>Event Handler of</H3>
<P><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>例子</H3>
<P>In the following example, the onLoad event handler displays a greeting message after a web page is loaded.
<PRE>
<BODY onLoad="window.alert("Welcome to the Brave New World home page!")>
</PRE>
<H3>相关</H3>
<P><A HREF="ref_m-q.htm#onUnload_event" onUnload_event">onUnload</A> event handler
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onMouseOver_event"><H2>onMouseOver event handler</H2></A>
<P>
<P>A mouseOver event occurs once each time the mouse pointer moves over an object from outside that object. The onMouseOver event handler executes JavaScript code when a mouseOver event occurs.
<P>You must return true within the event handler if you want to set the status or defaultStatus properties with the onMouseOver event handler.
<P>See the relevant objects for the onMouseOver 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_h-l.htm#link_object" link_object">link</A>
<H3>例子</H3>
<P>
By default, the HREF value of an anchor displays in the status bar at the bottom of the Navigator when a user places the mouse pointer over the anchor. In the following example, the onMouseOver event handler provides the custom message "Click this if you dare."
<XMP><A HREF="tppmsgs/msgs0.htm#17" tppabs="http://home.netscape.com/"
onMouseOver="window.status='Click this if you dare!'; return true">
Click me</A></XMP>
<P>See <A HREF="ref_m-q.htm#onClick_event" onClick_event">onClick</A> for an example of using onMouseOver when the <A> tag's HREF attribute is set dynamically.
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onSelect_event"><H2>onSelect event handler</H2></A>
<P>
<P>A select event occurs when a user selects some of the text within a text or textarea field. The onSelect event handler executes JavaScript code when a select event occurs.
<P>See the relevant objects for the onSelect 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_t-z.htm#text_object" text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A>
<H3>例子</H3>
<P>The following example uses an onSelect handler in the <I>valueField</I> text object to call the selectState() function.
<PRE><INPUT TYPE="text" VALUE="" NAME="valueField" onSelect="selectState()"></PRE>
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onSubmit_event"><H2>onSubmit event handler</H2></A>
<P>
A submit event occurs when a user submits a form. The onSubmit event handler executes JavaScript code when a submit event occurs.
<P>You can use the onSubmit event handler to prevent a form from being submitted; to do so, put a <B>return</B> statement that returns false in the event handler. Any other returned value lets the form submit. If you omit the <B>return</B> statement, the form is submitted.
<P>See the relevant objects for the onSubmit 语法.
<H3>Event Handler of</H3>
<P><A HREF="ref_f-g.htm#form_object" form_object">form</A>
<H3>例子</H3>
<P>In the following example, the onSubmit event handler calls the formData() function to evaluate the data being submitted. If the data is valid, the form is submitted; otherwise, the form is not submitted.
<PRE>
form.onSubmit="return formData(this)"
</PRE>
<P>相关 the 例子 for the <A HREF="ref_f-g.htm#form_object" form_object">form</A> object.
<H3>相关</H3>
<LI><A HREF="ref_s-s.htm#submit_object" submit_object">submit</A> object
<LI><A HREF="ref_s-s.htm#submit_method" submit_method">submit</A> method
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="onUnload_event"><H2>onUnload event handler</H2></A>
<P>An unload event occurs when you exit a document. The onUnload event handler executes JavaScript code when an unload event occurs.
<P>Use the onUnload event handler within either the <BODY> or the <FRAMESET> tag, for example, <TT><BODY onUnload="..."></TT>.
<P>In a <FRAMESET> and <FRAME> relationship, an onUnload event within a frame (placed in the <BODY> tag) occurs before an onUnload event within the <FRAMESET> (placed in the <FRAMESET> tag).
<H3>Event Handler of</H3>
<P><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>例子</H3>
<P>In the following example, the onUnload event handler calls the cleanUp() function to perform some shut down processing when the user exits a web page:
<PRE>
<BODY onUnload="cleanUp()">
</PRE>
<H3>相关</H3>
<P><A HREF="ref_m-q.htm#onLoad_event" onLoad_event">onLoad</A> event handler
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="open_document_method"><H2>open method (document object)</H2></A>
<P>
Opens a stream to collect the output of write or writeln methods.
<H3>语法</H3>
<PRE>document.open(["<I>mimeType</I>"])</PRE>
<P>
<I>mimeType</I> specifies any of the following document types:
<PRE>
text/htm
text/plain
image/gif
image/jpeg
image/x-bitmap
<I>plugIn</I>
</PRE>
<I>plugIn</I> is any two-part plug-in MIME type that Netscape supports.
<H3>Method of</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>Description</H3>
<P>The open method opens a stream to collect the output of write or writeln methods. If the <I>mimeType</I> is text or image, the stream is opened to layout; otherwise, the stream is opened to a plug-in. If a document exists in the target window, the open method clears it.
<P>End the stream by using the document.close() method. The close method causes text or images that were sent to layout to display. After using document.close(), issue document.open() again when you want to begin another output stream.
<P><I>mimeType</I> is an optional argument that specifies the type of document to which you are writing. If you do not specify a <I>mimeType</I>, the open method assumes <TT>text/htm</TT> by default.
<P>Following is a description of <I>mimeType</I>:
<LI><I>text/htm</I> specifies a document containing ASCII text with htm formatting.
<LI><I>text/plain</I> specifies a document containing plain ASCII text with end-of-line characters to delimit displayed lines.
<LI><I>image/gif</I> specifies a document with encoded bytes constituting a GIF header and pixel data.
<LI><I>image/jpeg</I> specifies a document with encoded bytes constituting a JPEG header and pixel data.
<LI><I>image/x-bitmap</I> specifies a document with encoded bytes constituting a bitmap header and pixel data.
<LI><I>plugIn</I> loads the specified plug-in and uses it as the destination for write and writeln methods. For example, "x-world/vrml" loads the VR Scout VRML plug-in from Chaco Communications, and "application/x-director" loads the Macromedia Shockwave plug-in.
<H3>例子</H3>
The following function calls document.open() to open a stream before issuing a write method:
<PRE>
function windowWriter1() {
var myString = "Hello, world!"
msgWindow.document.open()
msgWindow.document.write("<P>" + myString)
msgWindow.document.close()
}
</PRE>
In the following example, the <I>probePlugIn()</I> function determines whether a user has the Shockwave plug-in installed:
<PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -