JS document properties and Event Encyclopedia

Source: Internet
Author: User
Tags date format character set file size key reference variable window
Js

Object Properties

Document.title//Set document title equivalent to HTML <title> label

Document.bgcolor//Set page background color

Document.fgcolor//Set foreground colors (text color)

Document.linkcolor//not-clicked link color

Document.alinkcolor//Activate the color of the link (focus on this link)

Document.vlinkcolor//clicked on link color

Document. URL//Set URL property to open another page in the same window

Document.filecreateddate//File creation date, read-only property

Document.filemodifieddate//File modification date, read-only property

Document.filesize//File size, read-only property

Document.cookie//Set up and read out cookies

Document.charset//Set character set Simplified Chinese: gb2312

---------------------------------------------------------------------

Object methods

document.write ()///write content dynamically to page

Document.createelement (tag)//Create an HTML tag object

document.getElementById (ID)//Get object with specified ID value

Document.getelementsbyname (name)//Get object with specified Name value

---------------------------------------------------------------------

Images collection (image on page)

A) by reference to the collection

Document.images// labels on the corresponding page

Number of tags on the document.images.length//corresponding page

Document.images[0]//1th tags

Document.images[i]//First i-1 label

b) Direct reference through the Nane property

Document.images.oImage//document.images.name Properties

c) referencing the SRC attribute of a picture

Document.images.oImage.src//document.images.name properties. src

d) Create an image

var oimage

Oimage = new Image ()

Document.images.oimage.src= "1.jpg"

At the same time, create a label on the page to show the corresponding

<script language= "JavaScript" >

var oimage

Oimage = new Image ()

Document.images.oimage.src= "1.jpg"

</script>

----------------------------------------------------------------------

Forms collection (Forms on page)

A) by reference to the collection

Document.forms//<form> labels on the corresponding page

Number of <form> tags on the document.forms.length//corresponding page

Document.forms[0]//1th <form> tags

Document.forms[i]//First i-1 <form> label

Number of controls in Document.forms[i].length//I-1 <form>

DOCUMENT.FORMS[I].ELEMENTS[J]//i-1 <form> j-1 controls

b) direct reference through the label Name property

<form name= "Myform" ><input name= "Myctrl" ></form>

Document. Myform.myctrl//document. Table Single-name. Control Name

-----------------------------------------------------------------------

<!--text control related script-->

<form name= "Myform" >

<input type= "text" name= "Otext" >

<input type= "Password" name= "OPSWD" >

<form>

<script language= "JavaScript" >

Get the value of the text password box

document.write (document. Myform.oText.value)

document.write (document. Myform.oPswd.value)

</script>

-----------------------------------------------------------------------

<!--Select control related script-->

<form name= "Myform" >

<select name= "Oselect" >

<option value= "1" >1</option>

<option value= "2" >2</option>

<option value= "3" >3</option>

</select>

</form>

<script language= "JavaScript" >

To traverse the option item of a Select control

var length

Length=document. Myform.oSelect.length

for (i=0;i<length;i++)

document.write (document. Myform.oselect[i].value)

</script>

<script language= "JavaScript" >

Traverses the option and determines whether an option is selected

For (i=0;i<document. myform.oselect.length;i++) {

if (document. Myform.oselect[i].selected!=true)

document.write (document. Myform.oselect[i].value)

Else

document.write ("<font color=red>" +document. Myform.oselect[i].value+ "</font>")

}

</script>

<script language= "JavaScript" >

Print out selected option according to SelectedIndex

(0 to document.) MYFORM.OSELECT.LENGTH-1)

I=document. Myform.oSelect.selectedIndex

document.write (document. Myform.oselect[i].value)

</script>

<script language= "JavaScript" >

Dynamically increase the option item for a Select control

var ooption = document.createelement ("option");

ooption.text= "4";

Ooption.value= "4";

Document. Myform.oSelect.add (ooption);

</script>

-----------------------------------------------------------------------

<div id= "Odiv" >Text</Div>

DOCUMENT.ALL.ODIV//reference layer Odiv

Document.all.oDiv.style

Document.all.odiv.style.display= ""//Layer set to Visual

Document.all.odiv.style.display= "None"//layer set to hidden

/*document.all represents a collection of all objects in the document

Only IE supports this attribute, so it is also used to determine the type of browser.

INPUT element

The input element is used to define text entity objects and contains specific provisions for the format, data type, length, value, variable name, and so on of the input text content. When a user enters a rule that satisfies the input element, the input information is received and assigned to the specified variable for the appropriate operation, processing, otherwise, through the browser to give specific processing advice, and do is a single input processing or variable initialization operations, such as refreshing the card to let the user re-enter, Or to the user to indicate the input error and wait for further processing instructions. The input element is an important element in WML programming that handles user interaction activities, defined by a separate <input/> tag, and has the following syntax format:

<input name= "Variable" title= "label" type= "type" value= "value" default= "" Default "format=" specifier "emptyok=" false |true "size=" n "maxlength=" n "tabindex=" n "/>

Other properties are optional except that the Name property is required. The features and usage of these properties are described below: 1 name. This property is used to specify the variables and names that are used to hold user input text. After the Name property is defined, WML will store space for the text entity object that is about to be entered, depending on the property or variable name, to receive user input.

2) title. This property is used for the label of the input element, usually the hint information that is positioned before the input box.

3) type. Used to specify the type of text input area, with text and password two choices. The default value is text, and the specified user can enter text, and the text that is entered is gradually responded to and displayed in the browser. If you select password, the specified user-entered text is processed as password text, and the WML program receives input data as a text entity, and the browser responds to the user input display as an asterisk (*), which is used for confidentiality purposes.

4) value. This property is used to specify the value of the variable defined by the Name property, which is displayed in the input box.

5) Default. This property is used to specify the default value for the variable defined by the Name property.

6) format. This property is used to format the entered data.

7) MaxLength. This property is used to specify the maximum length that a user can enter a string. The upper limit of this property is 256, up to 256 characters.

8) Emptyok. Lets you specify whether users can enter content in the input box.

9) size. This property is used to specify the width of the input box, and the width value is the number of characters.

) TabIndex. Allows you to specify where multiple input boxes exist, similar to the TAB key in HTML.

Onabort is triggered when a user interrupts downloading an image.
OnActivate is triggered when an object is set to an active element.
The document associated with the Onafterprint object is immediately triggered on the object after printing or printing preview.
Onafterupdate is triggered on a data-bound object when the associated object in the data source object is successfully updated.
The Onbeforeactivate object is triggered immediately before it is set to the current element.
Onbeforecopy is fired in the source object before it is copied to the system Clipboard in Central.
Onbeforecut-Zhong District is fired from the source object before it is deleted from the document.
Onbeforedeactivate fires immediately before activeelement changes from the current object to other objects in the parent document.
Onbeforeeditfocus is triggered before an object contained within an editable element enters the user interface activation state or when an editable container becomes a control check area.
Onbeforepaste is triggered on the target object before pasting from the system Clipboard to the document in the selected area.
The Onbeforeprint object's associated document is triggered on the object before it prints or prints a preview.
onBeforeUnload is triggered before the page will be unloaded.
Onbeforeupdate is triggered on a data-bound object before the associated object in the data source object is successfully updated.
Onblur is triggered when an object loses input focus.
Onbounce is triggered when the behavior property of the marquee object is set to "alternate" and the contents of the caption reach the side of the window.
Oncellchange is triggered when data changes are in the data provider.
OnChange is triggered when the contents of an object or selection change.
OnClick triggers when the user clicks the object with the left mouse button.
OnContextMenu is triggered when a user opens a context menu using the right mouse button to click the client area.
Oncontrolselect is triggered when the user is about to make a control selection for the object.
Oncopy triggers on the source element when the user replicates the object or selection and adds it to the system Clipboard.
Oncut is triggered on the source element when the object or selection is deleted from the document and added to the system Clipboard.
ondataavailable fires whenever data from a data source object that transmits data asynchronously arrives.
Ondatasetchanged is triggered when a data set corresponding to a data source object has changed.
A ondatasetcomplete trigger indicates that all data for the data source object is available.
OnDblClick is triggered when the user double-clicks the object.
OnDeactivate is triggered when the activeelement changes from the current object to another object in the parent document.
Ondrag continues to fire on the source object when a drag operation is in progress.
Ondragend triggers on the source object when the user releases the mouse after the drag operation finishes.
OnDragEnter triggers on the target element when the user drags the object to a legitimate drag target.
OnDragLeave triggers on the target object when the user moves the mouse out of the legitimate drag target during the drag operation.
OnDragOver when a user drags an object across a legitimate drag target, it continues to trigger on the target element.
Ondragstart triggers on the source object when the user starts dragging the text selection or when the object is selected.
OnDrop triggers on the target object when the mouse button is released during the drag operation.
OnError is triggered when an error occurs during object loading.
Onerrorupdate is triggered on a data-bound object when an error occurs updating the associated data in the data source object.
Onfilterchange is triggered when a visual filter changes state or completes a transformation.
OnFinish is triggered when the caption loop completes.
Onfocus is triggered when the object gets focus.
Onfocusin is triggered before the element will be set to focus.
Onfocusout triggers immediately after the focus is moved to the other element, triggering on the element that currently has focus.
OnHelp is triggered when the user presses the F1 key when the browser is the current window.
OnKeyDown is triggered when the user presses the keyboard key.
OnKeyPress is triggered when the user presses a literal key.
OnKeyUp is triggered when the user releases the keyboard key.
Onlayoutcomplete is triggered when the print or Print preview layout finishes populating the current Layoutrect object with content from the source document.
OnLoad fires immediately after the browser finishes loading the object.
Onlosecapture is triggered when the object loses mouse capture.
OnMouseDown is triggered when a user clicks an object with any mouse button.
Onmouseenter is triggered when the user moves the mouse pointer inside the object.
OnMouseLeave is triggered when the user moves the mouse pointer out of an object boundary.
OnMouseMove is triggered when the user moves the mouse over the object.
onMouseOut is triggered when the user moves the mouse pointer out of an object boundary.
onMouseOver is triggered when the user moves the mouse pointer inside the object.
OnMouseUp is triggered when the user releases the mouse button while the mouse is over the object.
OnMouseWheel is triggered when the mouse wheel button rotates.
OnMove triggers when an object is moved.
Onmoveend is triggered when the object stops moving.
Onmovestart is triggered when the object begins to move.
Onpaste triggers on the target object when the user pastes data to transfer data from the system Clipboard to the document.
Onpropertychange is triggered when a property change occurs on an object that occurs on the object.
onReadyStateChange is triggered when an object's state changes.
OnReset is triggered when the user resets the form.
OnResize is triggered when the size of the object is about to change.
Onresizeend is triggered when the user changes the size of the object in the selection area of the control.
Onresizestart is triggered when the user starts to change the size of the object in the control's check area.
The onrowenter trigger indicates that the current row has been changed in the data source and that there are new data values available on the object.
Onrowexit fires before the data source control changes the current row of the object.
Onrowsdelete is triggered when the row is to be deleted from the recordset.
Onrowsinserted is triggered when a new row is inserted in the current Recordset.
Onscroll is triggered when the user scrolls the scroll bar of an object.
Onselect is triggered when the current selection changes.
Onselectionchange is triggered when the selected state of the document changes.
The Onselectstart object will be triggered when it is about to be selected.
OnStart is triggered at the beginning of each loop of the marquee object.
OnStop is triggered when the user clicks the Stop button or leaves the Web page.
OnSubmit is triggered when the form is to be committed.
OnUnload fires immediately before the object is unloaded.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.