The window object and screen object in js

The window object represents the window opened in the browser

Commonly used property
window.closed Whether the window has been closed
window.opener returns the
window.innerHeight applied to the window that created this window. The height of the
window document display area window.innerWidth The width of the window document display area
window.localStroage The key-value pair stored locally in the browser (no The expiration time is until manually deleted)
window.sessionStroage The browser temporary window saves the session data, and the
window.location is cleared when the window is closed.

  • Hash URL anchor part
  • host URL host name and port number
  • hostname URL hostname
  • href full URL link name
  • pathname URL path name
  • port service port number
  • protocol URL protocol
  • search URL query part

Related methods

window.location.assign('https://www.baidu.com/') //载入一个新的文档
window.location.reload() //重新载入当前文档
window.location.replace(newURL)  //用新文档代替当前文档
window.localtion.href=''https://www.baidu.com" //跳转链接

window.name Return or modify the name of the window
window.outerWidth //The external width of the window (including toolbars and scroll bars)
window.outerHeight //The external height of the window (including toolbars and scroll bars)
window.pageXOffset //Set or Returns the position of the current page relative to the X in the upper left corner of the window display area
window.pageYOffset //Sets or returns the position of the current page relative to the Y in the upper left corner of the window display area
window.screen returns the system property of the Screen object
parent returns the parent window
window. screenX returns the X coordinate value
relative to the screen window window.screenY returns the Y coordinate value relative to the screen window
window.self returns a reference to the current window
window.status sets the status window text
window.top returns the topmost parent window
Common methods
alert( ) Displays an alert box with a message and a confirmation button
atob() decodes a base-64 encoded string.
btoa() creates a base-64 encoded string.
blur() leave the keyboard focus from the top level
setInterval() set the timer
setTimeout() set the timeout
clearInterval() clear the timer
clearTimeout() clear the timeout
close() close the current window
confirm() pop-up confirmation box
createPopup() Create a Pop-up window
focus() Assign the focus keyboard to a window
moveBy (x,y) Move the relative window coordinates to the specified pixel
moveTo(x,y) Move the relative window coordinates to the specified position
open() Open a browser window or find a named window

window.open(URL,name,specs,replace)
  • URL link address
  • name: window name
  • specs window specified attributes
  • replace whether to replace the current window (true or false)

print() print the content of the current window
prompt () display a dialog box that prompts the user to input
resizeBy() adjust the window size according to the specified pixel resizeTo()
adjust the window size to the specified width and height
scrollBy() according to the specified pixel value Scroll content
scrollTo() Scroll content according to the specified height
stop() Stop page loading

screen contains information about the client's display screen

screen.availHeight the height of the screen (not including the taskbar)
screen.availWidth the width of the screen (not including the taskbar)
screen.colorDepth the bit depth of the palette on the target device or buffer
screen.height the total height of the
screen screen.width screen The total width of
screen.pixelDepth and the color resolution
of the screen are all readable attributes

Guess you like

Origin blog.csdn.net/qq_40969782/article/details/115301337