JavaScript window and Document Object Detail _ Basics

Source: Internet
Author: User
One, Window object
-------------------------------------------------- -------------------
Object Properties
window//window itself
Window.self//reference to the window window=window.self
Window.name//name for Windows
Window.defaultstatus//Set window status bar information
Window.location//url address, equipped with this property to open a new page
-------------------------------------------------- -------------------
Object methods
Window.alert ("text")//Prompt Info Session box
Window.confirm ("text")//Confirmation Session Box
Window.prompt ("text")//Require keyboard input session box
Window.setintervel ("Action", time)//every interval specified (milliseconds) to perform an action
Window.clearinterval ()//clearance time equipped with the function is to terminate the reincarnation
Window.settimeout (action,time)//interval specified time (in milliseconds) perform one action
window.open ()//Open a new window
Window.close ()//Close Windows
-------------------------------------------------- -------------------
Member objects
Window.event
Window.document//See Document Object detailed
Window.history
Window.screen
Window.navigator
window.external
-------------------------------------------------- -------------------
Window.history objects
Number of window.history.length//browsed pages
History.back ()//Retreat
History.forward ()//Progress
History.go (i)//forward or head back to page I of history
I>0 Progress, I<0 Retreat
-------------------------------------------------- -------------------
Window.screen objects
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 (remove height of taskbar)
-------------------------------------------------- -------------------
window.external objects
Window.external.AddFavorite ("Address", "title")//Add the website to the Preservation folder
-------------------------------------------------- -------------------
Window.navigator objects
Window.navigator.appCodeName//Browser code name
Window.navigator.appName//Browser pace 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, ditto
Window.navigator.appVersion//Browser version (including system version)
Window.navigator.userAgent
Window.navigator.onLine//user no online
Whether the window.navigator.cookieEnabled//browser supports cookies
Window.navigator.mimeTypes
==================================================

Ii. Object of document

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
----------------------------

Common 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
Document.body.appendChild (Otag)

body-the principal child object

Document.body//Specifies that the start and end of the document body is equivalent to <body></body>
Document.body.bgColor//Sets or gets the background color behind the object
Document.body.link//not-clicked link color
Document.body.alink//Activate the color of the link (focus on this link)
Document.body.vlink//clicked on link color
Document.body.text//Text color
Document.body.innerText//Set text between <body>...</body>
Document.body.innerHTML//Set HTML code between <body>...</body>
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 picture
Document.body.appendChild (Otag)//dynamically generate an HTML object
Common Object Events

Document.body.onclick= "func ()"//mouse pointer Click object is triggered
Document.body.onmouseover= when the "func ()"//mouse pointer moves over an object
Trigger when document.body.onmouseout= "func ()"//mouse pointer moves out of an object
location-Position child Object
Document.location.hash//#号后的部分
Document.location.host//Domain name + port number
Document.location.hostname//Domain
Document.location.href//Full URL
Document.location.pathname//directory section
Document.location.port//Port number
Document.location.protocol//Network Protocol (http:)
Document.location.search//number of parts after

Common Object Events
Documeny.location.reload ()//Refresh Page
Document.location.reload (URL)//Open new page
Document.location.assign (URL)//Open new page
Document.location.replace (URL)//Open new page
========================================================================
selection-Selection Child Objects
Document.selection
========================================================================
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
----------------------------
Sample 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"
</script>
Related Article

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.