Common parts of BOM-browser Object Model

Source: Internet
Author: User

The content of this article comes from different places. Sort it by yourself.
DOM objects are often discussed. Another important object is Bom-browser object model.


1. Top and parent point to different content. Top must point to the outermost window. The parent points to the parentframe of the current frame. Because the browser window itself is regarded as the parent framework of all top-level frameworks.

2. self is a more progressive window pointer, which is always equal to window (it is added because it is more suitable than parent. It clarified that what is being used is not the parent framework of the framework, but itself ). If there is no frame on the page, window and self are equal to top, and the frames set length is 0.

3. Window objects are useful for operating browser windows (and frameworks. There are four operation windows:
(1) moveBy (dx, Dy) -- move DX pixels and Dy pixels horizontally from the browser window to the current position. The DX value is negative, and the window is moved to the left. The DY value is negative, and the window is moved up.
(2) moveTo (x, y) -- move the browser window so that its upper left corner is located at (x, y) of the user screen. You can use a negative number, but this will remove some windows from the visible area of the screen.
(3) resizeBy (DW, DH)-adjust the width of its port to DW pixels and the height to Dy pixels relative to the current size of the browser window. DW is a negative number, narrowing down the window width, Dy is a negative number, narrowing the window height.
(4) resizeTo (W, h) -- Adjust the window width to W and the height to H. Negative numbers cannot be used.
(5) IE provides window. screenleft and window. screentop objects to determine the position of the window. However, no method is provided to determine the window size. You can use the document. Body. offsetwidth and document. Body. offsetheight attributes to obtain the size of the view (display the area of the HTML page), but they are not standard attributes.
(6) Mozilla provides the window. screenx and window. screeny attributes to determine the position of the window. It also provides the window. innerwidth and window. innerheight attributes to determine the size of the window. outerwidth and window. outerheight attributes to determine the size of the browser window.

4. The window. open () method opens a new window. Window. open () has three parameters. If you call the existing framework as the second parameter of the window. open () method, the page indicated by the URL will be loaded into the framework. If the declared framework name is invalid, window. open () opens a new window. The features of this window are determined by the third parameter (feature string. If the third parameter is omitted, a new browser window is opened, Just Like clicking the link where the target is set to _ blank. This means that the settings of the new browser window are the same as those of the default browser window (the toolbar, address bar, and status bar are both visible.

5. Confirm () Prompt () of alert (). The return value of prompt is the value in the text box. These three dialogs are system windows, which means that the windows displayed in different operating systems (sometimes in different browsers) may be different. This also means that it is impossible to control the font, color, and other appearances of the window.

6. Operation Status Bar. The status bar tells you when to load the page and when to load the page, corresponding to the window. Status and window. defaultstatus attributes. Status changes the text of the status bar temporarily. defaultstatus changes the text until the user leaves the current page.

7. When setTimeout () is called, it creates a digital pause ID, which is similar to the process ID in the operating system. The pause ID is essentially the ID of the process to be delayed. After setTimeout () is called, you should not execute otherCode. To cancel a pause that has not been executed, call the cleartimeout () method and pass the pause ID to it. If you wait for a period of time before executing a group of Specified Code, use pause. Loop setTimeout () can be used for repeated calls. If you want to execute some code repeatedly, use the time interval. Setinterval () to clear clearinterval ().

8. histroty. Length indicates the history.

9.doc ument. Write and document. writeln methods help render. If any method is called after the page is loaded, it will erase the page content and display the specified content.

10. Location object. One of the most useful objects in Bom is the location object, which is the property of the window object and the Document Object (there is no standard for this, leading to some confusion ). The location object indicates the URL of the loading window. In addition, it can parse the URL:
(1) hash -- if the URL contains #, this method returns the content after the symbol.
(2) host -- the name of the server (for example, ).
(3) hostname -- usually equal to host, and sometimes the previous WWW is omitted.
(4) href: the complete URL of the currently loaded page.
(5) pathname -- the part after the host name in the URL.
(6) port -- the request port declared in the URL. By default, most URLs do not have port information, so this attribute is usually blank. The port property for a URL like 3345/default. asp is 3345.
(7) Protocol-the protocol used in the URL, that is, the section before the double slash. For example, the Protocol property in the is equal to the Protocol property of the http: is equal to FTP :.
(8) Search -- question mark (?) in the URL where the GET request is executed (?) Is also called a query string. Example. Content_id = the search attribute in 60 is equal? Content_id = 60
(9) location. href is the most common attribute used to obtain or set the URL of the window (in this regard, it is similar to the document. url attribute ). Change the value of this attribute to navigate to the new page. In this way, the new address will be added to the browser's history stack and placed on the previous page, which means that the back button will navigate to the page that calls this attribute. The assign () method can also perform the same operation. Use the Replace () method if you do not want pages containing scripts to be accessed from the browser history. This method performs the same operations as the assign () method, but it takes one more step to delete a page containing scripts from the browser history, in this way, you cannot access the browser through the back and forward buttons. The location object also has a reload () method to reload the current page. The reload () method can be reloaded from the browser cache or from the server. If it is false, it is loaded from the cache. If it is true, it is loaded from the server (if the parameter is omitted, the default value is false ).

11. navigator object.
(1) appcodename: String Representation of the browser code name (such as "Mozilla ").
(2) appname-String Representation of the official browser name.
(3) appminorversion: String Representation of additional version information.
(4) appversion: String Representation of the browser version information.
(5) browserlanguage: String Representation of the browser or operating system language.
(6) cookieenabled -- indicates whether the Boolean value of cookie is enabled.
(7) cpuclass -- string representation of the CPU category ("x86", "68 K", "Alpha", "PPC", or "other ").
(8) javaenabled () -- indicates whether Java's Boolean value is enabled.
(9) language-String Representation of the browser language.
Not every browser supports these attributes.

12. The Screen Object usually contains the following attributes.
(1) availheight: the height (in pixels) of the screen that can be used by the window, including the space required by operating system elements (such as Windows toolbar.
(2) availwidth: the width (in pixels) of the screen that can be used by the window ).
(3) colordepth: the number of digits in the color. Most systems use 32-bit.
(4) Height: the screen height (in pixels ).
(5) width: the screen width (in pixels ).

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