Basic knowledge of JavaScript BOM

Source: Internet
Author: User

1.BOM (Bowser object Model Explorer)

  A browser-created object is often referred to as a Document object, which is part of the many objects used by the browser, and the browser-manipulated object is called the browser object model (Bowser object mode), or BOM.

2. The Window object is a top-level object that contains information about the windows of the document

2.1 Document Object

  • Document Object collection
    • images[]      //Picture Object array
    • links["         //Connection object array
    • form["         //Form Object array
  • Document Object Properties
    • cookie          //Set or return the current document All related cookies
    • domain        //returns the domain name of the current document for security purposes, String type
    • referrer        //returns the URL loaded into the current document
    • Li> title              //returns the title of the current document
    • url            //Returns the URL of the current document
    • bgcolor   ;      //Set the background color of the document
    • fgcolor        // Sets the foreground color of the document
    • linkcolor      //Set the unreachable connection color
    • Span style= "color: #008080;" >vlinkcolor    /Set the accessed connection color
  • Document Object method
    • Open ()//opens a new document and erases the contents of the old document
    • Close ()//Turn off open () document output stream
    • Write ()//insert a string into the current document or add a string at the end of open ()
    • Writeln ()//is the same as write (), just adds a carriage return string at the end of the output string

2.2 Screen object (Display object)

    • Screen Object Properties
      • availheight//Screen available height, unit: px
      • Availwidth//Screen available width
      • Height//Screen altitude
      • Width//Screen widths
      • colordepth//color depth, expressed using pixel digits

2.3 Location Object (Position object)

  • Location Object Properties
    • hash                //Sets or returns a URL starting from #
    • host             & nbsp  //Sets or returns the host name and the current URL port number
    • hostname        // Sets or returns the host name of the current URL
    • href               &NBS p;//Sets or returns the full URL
    • pathname        //Sets or returns the path portion of the current URL
    • port                //set or return the current URL Port section of
    • protocol          //set or return the protocol for the current URL
    • search            //set or return from? Start URL
  • Method of the Location object
    • Reload (force)//reload the current page, parameter forces is an optional parameter whose value is true when loading is forced to complete
    • Replace (URL) //replaces the current page with the specified URL, but does not produce a new enlistment in the browser history, which is the difference between this method and the value assigned to the HREF attribute
    • Assign (URL)//Loading a new document

2.4 History Object (historical object)

    • History Object method
      • Back ()//return to the page that the user has just visited
      • Forward ()//Return to next page
      • Go (n)//jump to the page represented by the nth URL of the current page, positive value indicates forward, negative value indicates back. Go (-1) is equivalent to back ()

2.5 window Control

    • Moveby (Dx,dy)//Move the window from the current position to the specified distance
    • MoveTo (x, y)//Move the current window to the specified position
    • Resizeby (DW,DH)//Zoom window to the specified amount
    • Resizeto (width,height)//Change the window size to the specified width and height
    • Scrollby (Dx,dy)//Scrolls the contents of the window by the specified amount
    • ScrollTo (x, y)//Scrolls the contents of the window to the specified position

2.6 Focus Control

    • Focus//Get focused
    • Blur//Remove focus

2.7 Opening and closing windows

    • Open window
      • Syntax:open ("URL", "Window name", "Window Style")
      • Function: Opens a window of a row and loads the page with the specified URL address in the window
      • Window style: Height (height of window), Width (window width), left (window coordinates), Top (window coordinates), location (yes |no) show Address bar, menubar (yes |  NO) displays the menu bar, resizable (yes | NO) whether the window size can be changed, scrollbars (yes |no) whether the scrollbar is allowed, the status (yes |no) is allowed to display the State Bar, toolbar (yes |no) whether the toolbar is displayed
    • Close window
      • Close ()
      • Function: Auto Close window

2.8 Timers

    • SetTimeout (Execution code, number of milliseconds)//to the specified number of milliseconds, automatic function code execution
    • Cleartimeout (timer)//Cancel timer set by settimeout ()
    • SetInterval (Repeat code, number of milliseconds)//Repeat function code by specified period
    • Clearinterval (Time spacer)//Cancel the time interval set by SetInterval ()

2.9 dialog box

    • alert ("Hint string") //pop up a warning box to display the prompt character in the warning box
    • confirm ("hint string") //Popup A confirmation box, display prompt character in confirmation box, return True when user clicks "Confirm" button, return False when clicking "Cancel"
    • prompt ("hint string", "Default text") //pops up an input box, displays the prompt string in the input box, displays the default text in the Input text box, and waits for user input when the user clicks "OK" to return the User input string, click "Cancel", return null

2.10 Properties

    • status bar
      • defaultstatus & nbsp            //Change browser status bar default display
      • status   &N Bsp                    //Temporarily change browser status bar display
    • window position
    • ie browser  
      • scrollleft  |  scrolltop                          &NBS P                          ,         &NB Sp                                //window upper left corner x-coordinate , y-coordinate
      • document.documentelement.scrollleft/scrolltop   or document.body.scrollleft/scrolltop  // The current document is scrolled to the right, down the pixel
    • Firefox browser
      • Innerheight | Innerwidth //Returns the height and width of the document display area of the window (excluding menu bars, toolbars, scroll bars) units: px
      • Outheight | Outwidth//Returns the total height and width of the window (including menu bar, toolbar, scroll bar) units: px
    • ! IE browser
      • ScreenX | ScreenY //Window upper-left corner x-coordinate, y-coordinate
      • Pagexoffset |pageyoffset//Current document to the right, scroll down the pixels
    • Other properties
      • Name//Set or return window name
      • Self//Returns a reference to the current window
      • Closed//Returns True when the window is closed
      • Opener

2.11 Navigator Object (Navigator object)

    • Navigator Object Properties
      • appCodeName//Return the code name of the browser
      • Appnode//Return browser name
      • AppVersion//Return browser platform and version information
      • cookieenabled//Returns the Boolean value of whether cookies are enabled in the browser, with a value of true when turned on, or false
      • Platform//Return to the operating system platform that the browser is running
      • UserAgent//Returns the value of the user agent header used by the browser in an HTTP request
    • Navigator Object Methods
      • javaenabled ()//If the browser supports Java and turns on Java support, returns true, otherwise false

Basic knowledge of JavaScript BOM

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.