The window object

  • At the heart of the BOM is the Window object, which represents an instance of the browser.
  • The global variables and functions declared by var become properties and methods of the window object
  • Let const does not

Window position to pixel ratio

  • Window.moveto (x, y) movement positions are absolute coordinates
  • MoveBy (x, y) is the relative coordinate
  • Window. DevicePixelRatio Pixel ratio (not yet)

The window size

  • The size of the page viewport of the browser window (excluding toolbar and sidebar)
  • OuterWidth outerHeight Size of the browser window ()
  • Document. The documentElement. ClientWidth and document. DocumentElement. ClientHeight viewport width high returns page
  • Document.com patMode is used to determine the rendering mode adopted by the current browser.
    • BackCompat: The standards-compliant mode is disabled. Width of the browser client area is the document. The body. ClientWidth;
    • CSS1Compat: enable the standard compatibility mode. Width of the browser client area is the document. The documentElement. ClientWidth
  • Resize the window
    • Window.resizeto () accepts the new width and height values
    • Window.resizeby () accepts how much width and height to scale
  • Adjust palatability position (Support behavior property: indicates smooth movement)
    • Scroll ()
    • ScrollTo () Scroll coordinates
    • ScrollBy () The scrolling distance
  • Navigate and open a new window
    • window.open()
  • The timer
    • setTimeout & clearTimeout
    • setInterval & clearInterval
  • System dialog box
    • Alert (), confir, prompt()
    • Window.find () displays the find dialog box
    • Window.print () displays the print dialog box

Location object

  • The value after the location.hash #

  • Location. host Specifies the server name and port number

  • Location. hostName Specifies the server name

  • Location. href Current URL path

  • The same goes for the location. The toString ()

  • Location. pathName The path and/or file name in the URL

  • The location. The port port

  • Protocol Protocol used by the page HTTP or HTTPS

  • The query string for location.search URL starts with? At the beginning

  • Location. origin The original URL address is read-only

  • Location. username specifies the username before the domain name

  • Location. password Specifies the password before the domain name

  • new URLSearchParams(location.search)

  • Modifying the Location object

    • window.assign(”)
    • window.location = ”
    • window.locatiobn.href = ”
    • window.location.replace(”)
    • The window.location.reload() ture parameter is optional

The navigator object

  • no

The screen object

  • no

The history object

  • window.history.go()
  • Window.history.back () advances one page
  • Window.history.forward () retreats one page
  • Window.history. length indicates how many entries there are in the history