window and Document objects

Source: Internet
Author: User

Note: The element Name property on the page and the names of the JavaScript references must be consistent including case
Otherwise you will be prompted with 1 error message "The referenced element is empty or not an object"

First, Window object
-------------------------------------------------- -------------------
Object Properties
Window//Windows themselves
Window.self//cite this window window=window.self
Window.name//Name the window
Window.defaultstatus//Setting window status bar information
Window.location//url address, equipped with this property to open a new page
-------------------------------------------------- -------------------
Object methods
Window.alert ("text")//Prompt Message session box
Window.confirm ("text")//Confirm session Box
Window.prompt ("text")//Require keyboard input session box
Window.setintervel ("Action", Time)//The operation is performed once every interval specified (in milliseconds)
Window.clearinterval ()//clear time equipped with the function is to terminate the cycle
Window.settimeout (action,time)//Interval of time (milliseconds) to perform an operation
window.open ()//Open a new window
Window.close ()//close the window
-------------------------------------------------- -------------------
Member objects
Window.event
Window.document//See Document Object detailed
Window.history
Window.screen
Window.navigator
window.external
-------------------------------------------------- -------------------
Window.history Object
Window.history.length//Number of pages viewed
History.back ()//Retreating retreat
History.forward ()//Progress
History.go (i)//go forward or head back to the first page of the history record
I>0 Progress, I<0 Retreat
-------------------------------------------------- -------------------
Window.screen Object
Window.screen.width//Screen width
Window.screen.height//Screen height
Window.screen.colorDepth//Screen color depth
Window.screen.availWidth//Available width
Window.screen.availHeight//Available height (drop taskbar height)
-------------------------------------------------- -------------------
Window.External Object
Window.external.AddFavorite ("Address", "title")//Add the website to the Preservation folder
-------------------------------------------------- -------------------
Window.navigator Object
Window.navigator.appCodeName//Browser code name
Window.navigator.appName//Browser step name
Window.navigator.appMinorVersion//Browser patch version
Window.navigator.cpuClass//CPU Type x86
Window.navigator.platform//Operating system type Win32
Window.navigator.plugins
Window.navigator.opsProfile
Window.navigator.userProfile
Window.navigator.systemLanguage//Customer System language ZH-CN Simplified Chinese
Window.navigator.userLanguage//user language, ibid.
Window.navigator.appVersion//Browser version (including system version)
Window.navigator.userAgent
Window.navigator.onLine//user no online
window.navigator.cookieEnabled//Browser supports cookies
Window.navigator.mimeTypes
==================================================

Ii. object of document

Object properties:
Document.title//Set document title equivalent to HTML <title> tags
Document.bgcolor//Set page background color
Document.fgcolor//Set foreground (text color)
Document.linkcolor//non-clicked link color
Document.alinkcolor//Activate link (focus on this link) color
Document.vlinkcolor//Clicked 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 sets Simplified Chinese: gb2312
----------------------------

Common Object Methods
document.write ()//write content to page dynamically
Document.createelement (tag)//Create an HTML tag object
document.getElementById (ID)//Get the object with the specified ID value
Document.getelementsbyname (name)//Gets the object with the specified Name value
Document.body.appendChild (Otag)
body-Principal Sub-object
Document.body//Specifies the beginning and end of a document body equivalent to <body></body>
Document.body.bgColor//Sets or gets the background color behind the object
Document.body.link//non-clicked link color
Document.body.alink//Activate link (focus on this link) color
Document.body.vlink//Clicked link color
Document.body.text//Text color
Document.body.innerText//Set text between <body>...</body>
Document.body.innerHTML//settings <body>...</body> HTML code between
Document.body.topMargin//page top margin
Document.body.leftMargin//Page left margin
Document.body.rightMargin//Page right margin
Document.body.bottomMargin//Page Bottom margin
Document.body.background//Background image
Document.body.appendChild (Otag)//dynamically generate an HTML objectCommon Object Events
Document.body.onclick= "func ()"//mouse pointer Click object is triggered
Document.body.onmouseover= "func ()"//mouse pointer is triggered when moving to an object
Document.body.onmouseout= "func ()"///mouse pointer is triggered when the object is moved outlocation-Position Sub-object

Document.location.hash//#号后的部分
Document.location.host//domain + port number
Document.location.hostname//Domain name
Document.location.href//Full URL
Document.location.pathname//directory section
Document.location.port//Port number
Document.location.protocol//Network Protocol (http:)
Section after Document.location.search//?

Common Object Events

Documeny.location.reload ()//Refresh Web page
Document.location.reload (URL)//Open a new page
Document.location.assign (URL)//Open a new page
Document.location.replace (URL)//Open a new page
========================================================================
selection-Selection Sub-object
Document.selection
========================================================================
Images collection (images in the page):
----------------------------
A) by collection reference
Document.images// tags on the corresponding page
Document.images.length//number of tags on the corresponding page
Document.images[0]//1th tags
Document.images[i]//i-1 tags
----------------------------
b) direct reference via Nane property

Document.images.oImage//document.images.name Properties
----------------------------
c) The SRC attribute of the reference picture
Document.images.oImage.src//document.images.name property. src
----------------------------
d) Create an image
var oimage
Oimage = new Image ()
Document.images.oimage.src= "1.jpg"
At the same time, create a tag on the page corresponding to the display
----------------------------
Example code (dynamically creating images):

<script language= "JavaScript" >
var oimage
Oimage = new Image ()
Document.images.oimage.src= "1.jpg"
</script>

<script language= "JavaScript" >
Oimage=document.caeateelement ("IMG")
Oimage.src= "1.jpg"

window and Document objects

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.