javascript手冊-b
javascript手冊-b back methodLoads the previous URL in the history list. 语法history.back()
用法history 描述This method performs the same action as a user choosing the Back button in the Navigator. The back method is the same as history.go(-1). 例子The following custom buttons perform the same operations as the Navigator Back and Forward buttons: <P><INPUT TYPE="button" VALUE="< Back" onClick="history.back()"><P><INPUT TYPE="button" VALUE="> Forward" onClick="history.forward()">
See alsoforward, go methods bgColor propertyA string specifying the color of the document background. 语法document.bgColor
Property ofdocument 描述The bgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the BGCOLOR attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You can set the bgColor property at any time. If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072". 例子The following example sets the color of the document background to aqua using a string literal: document.bgColor="aqua"
The following example sets the color of the document background to aqua using a hexadecimal triplet: document.bgColor="00FFFF"
See alsoalinkColor, fgColor, linkColor, and vlinkColor properties big methodCauses a string to be displayed in a big font as if it were in a <BIG> tag. 语法stringName.big()
stringName is any string or a property of an existing object. 用法string 描述Use the big method with the write or writeln methods to format and display a string in a document. 例子The following example uses string methods to change the size of a string: var worldString="Hello, world"document.write(worldString.small())document.write("<P>" + worldString.big())document.write("<P>" + worldString.fontsize(7))
The previous example produces the same output as the following htm: Hello, worldHello, worldHello, worldSee alsofontsize, small methods blink methodCauses a string to blink as if it were in a <BLINK> tag. 语法stringName.blink()
stringName is any string or a property of an existing object. 用法string 描述Use the blink method with the write or writeln methods to format and display a string in a document. 例子The following example uses string methods to change the formatting of a string: var worldString="Hello, world"document.write(worldString.blink())document.write("<P>" + worldString.bold())document.write("<P>" + worldString.italics())document.write("<P>" + worldString.strike())
The previous example produces the same output as the following htm: Hello, worldHello, worldHello, worldHello, worldSee alsobold, italics, strike methods blur methodRemoves focus from the specified object. 语法1. passwordName.blur()2. selectName.blur()3. textName.blur()4. textareaName.blur()
passwordName is either the value of the NAME attribute of a password object or an element in the elements array.
selectName is either the value of the NAME attribute of a select object or an element in the elements array.
textName is either the value of the NAME attribute of a text object or an element in the elements array.
textareaName is either the value of the NAME attribute of a textarea object or an element in the elements array. 用法password, select, text, textarea 描述Use the blur method to remove focus from a specific form element. 例子The following example removes focus from the password element userPass: userPass.blur()
This example assumes that the password is defined as: <INPUT TYPE="password" NAME="userPass">
See alsofocus, select methods bold methodCauses a string to be displayed as bold as if it were in a <B> tag. 语法stringName.bold()
stringName is any string or a property of an existing object. 用法string 描述Use the bold method with the write or writeln methods to format and display a string in a document. 例子The following example uses string methods to change the formatting of a string: var worldString="Hello, world"document.write(worldString.blink())document.write("<P>" + worldString.bold())document.write("<P>" + worldString.italics())document.write("<P>" + worldString.strike())
The previous example produces the same output as the following htm: <BLINK>Hello, world</BLINK><P><B>Hello, world</B><P><I>Hello, world</I><P><STRIKE>Hello, world</STRIKE>
See alsoblink, italics, strike methods button objectA pushbutton on an htm form. 语法To define a button: <INPUT TYPE="button" NAME="buttonName" VALUE="buttonText" [onClick="handlerText"]>
NAME="buttonName" specifies the name of the button object. You can access this value using the name property.
VALUE="buttonText" specifies the label to display on the button face. You can access this value using the value property. To use a button object's properties and methods: 1. buttonName.propertyName2. buttonName.methodName(parameters)3. formName.elements[index].propertyName4. formName.elements[index].methodName(parameters)
buttonName is the value of the NAME attribute of a button object.
formName is either the value of the NAME attribute of a form object or an element in the forms array.
index is an integer representing a button object on a form.
propertyName is one of the properties listed below.
methodName is one of the methods listed below. Property ofform 描述A button object on a form looks as follows: A button object is a form element and must be defined within a <FORM> tag. The button object is a custom button that you can use to perform an action you define. The button executes the script specified by its onClick event handler. Propertiesname reflects the NAME attribute value reflects the VALUE attribute Methodsclick Event handlersonClick 例子The following example creates a button named calcButton. The text "Calculate" is displayed on the face of the button. When the button is clicked, the function calcFunction() is called. See alsoform, reset, and submit objects