The core object of the BOM is window, this chapter has nothing to say, summed up some of the more commonly used:
1,a not defined,
A Error
WINDOW.A; Undefined
Cannot delete global variables with delete
2,HTML5 does not support <frame> tags, but supports <iframe> tags
The Top,opener,parent,self property of the Window object in 3,js (although, for window, they are a property, but can also be used directly as objects) the difference:
Top: This change always refers to the top-level browser window of the split window. If you plan to execute commands from the top level of the split window, you can use the top variable.
Opener: The object that is used to refer to the page that executes the window.open method on the window.open page. If a page uses window.open () page B, then we have to refer to page A in the B page, we can use the opener object, if it must be opened with the window.open () method to use;
Parent: The object that accesses the parent page in the resulting child page in Iframe,frame. For example: A page has an IFRAME or frame, then the page in the IFRAME or frame can refer to the object in page A through the parent object. This allows you to get or return a value to the a page. (not to be confused with jquery's parent () method)
Self: Refers to the current window
4, Window position
Screenleft,screentop:ie, Safari, Opera, Chrome
ScreenX, Screeny:firefox, Safari, Chrome
Get the top-left position of the window across browsers:
var leftpos = (typeof Window.screenleft = = "Number")? Window.screenLeft:window.screenX;
var toppos = (typeof window.screentop = = "Number")? Window.screenTop:window.screenY;
Window position movement (both methods may be disabled by the browser):
Window.moveto (200,200); Move the window down to 200 pixels and move right to 200 pixels. (0,0) is the upper-left corner of the screen
Window.moveby (-50,100); Move the window 100 pixels down, 50 pixels to the left
Web page Visible area width: document.body.clientWidth
Web page Visible area height: document.body.clientHeight
Web page Visible area width: document.body.offsetWidth (including edge width)
Web page Visible Area High: document.body.offsetHeight (including edge width)
page Body Full text width: document.body.scrollWidth
page Body Full text High: Document.body.scrollHeight
page is rolled away High: Document.body.scrollTop
webpage is rolled away left: Document.body.scrollLeft
page body part: Window.screentop
page body part left: Window.screenleft
High screen resolution: Window.screen.height
width of screen resolution: Window.screen.width
screen Available work area height: window.screen.availHeight
screen Available work area width: window.screen.availWidth
Page viewport size (cross-browser):
var pagewidth = window.innerwidth;
var pageheight = window.innerheight;
if (typeof pagewidth! = "Number") {
if (Document.compatmode = = "Css1compat") {
PageWidth = Document.documentElement.clientWidth;
PageHeight = Document.documentElement.clientHeight;
}else {
PageWidth = Document.body.clientWidth;
PageHeight = Document.body.clientHeight;
}
}
5,prompt (Que,ans);
Que: Problems with dialog boxes
Ans: Default Answer
6,location object:
window.location = = = Document.location;//true
Location.hash; a hash in//url
location.href;//Returns the full URL, if equal to a URL, is equivalent to jumping to this URL
location.host;//returns the server name and port number (if any)
location.hostname;//server name without port number
location.port;//Port number
location.protocol;//page uses the protocol, "http:" or "https:"
location.search;//url query string, to greet the beginning, you can use Location.search.substring (1), the question mark after all the string, where the string is encoded, To decode with decodeURIComponent (str)
7,uri three kinds of decoding and encoding comparison:
decodeURI () & encodeURI (): hexadecimal encoding, if the URL to jump, you can use it to encode, for example: Location.href=encodeuri (http://cang.baidu.com/do/s? word= Baidu &ct=21);
decodeURIComponent () & encodeURIComponent (): is also hexadecimal encoded, but more complex than the above, finer, special symbols will also be transcoded, so suitable for use as parameters, for example: <script language= "JavaScript" >document.write (' <a href= ' http://passport.baidu.com/?logout&aid=7&u= ' + encodeURIComponent ("Http://cang.baidu.com/bruce42") + ' > Exit </a> ');</script>
Escape () & Unescape (): Deprecated
8, position operation:
location.href= "url";//Recommended Use
location.assign= "url";//equal to the above
location.replace ("url");//jump can not back, this is somewhat similar to vue-router inside, this. $router. Push and this. $router the difference between replace
location.reload ();//Reload
9,navigator object:
mainly for the client browser some properties, many do not say,
Navigator.online;//Whether the network is connected
navigator.appname;//Browser Full name
10,screen object:
The most common is the resolution:
Window.screen.width/height
11,history object:
History.go (-1);//Back one page
History.go (1);//forward one page
History.back ();//Back one page
History.forward ();//forward one page
JavaScript learning Log (iv): BOM