Browser object model BOM (Browser Object Mode)

Source: Internet
Author: User

 

Bom mainly processes browser windows and frameworks. However, browser-specific JavaScript extensions are usually considered part of BOM. These extensions include:

1. Pop up a new browser window, move it, close the browser window, and adjust the window size;

2. Navigation Objects that provide detailed information about Web browsers;

3. Provides positioning objects loaded to detailed information on pages in the browser;

4. screen objects that provide detailed information about the user's screen resolution;

5. Support for cookies.

1. Window object:

1. window operations:

MoveBy (dx, Dy): Move the browser window x pixels horizontally relative to the current position, and move y pixels vertically.

MoveTo (x, y): Move the browser window so that the upper left corner of the window is located at (x, y) of the user screen.

ResizeBy (DW, DH): Adjust the width of the browser window to X pixels and the height to y pixels, relative to the current size of the browser window.

ResizeTo (W, h): Adjust the window width to X and the height to y. Cannot be negative.

★IE provides window. screenleft and window. screentop objects to determine the position of the window. The document. Body. offsetwidth and document. Body. offsetheight attributes can be used to obtain the size of the view.

★Mozilla provides window. screenx and window. the screeny attribute determines the position of the window. Windows. innerwidth and windows. the innerheight attribute is used to determine the size of the window. outerwidth and window. the outerheight attribute determines the size of the browser window.

2. Navigate to and open a new window:

Open a new window: window. Open ("URL of the new window", "name", "feature string ");

Various settings:

Left: The left coordinate of the window. It cannot be a negative number;

Top: the upper coordinate of the window. It cannot be a negative number;

Height: The window height, which cannot be less than 100;

Width: The window width, which cannot be less than 100;

Resizable: determines whether the form can be dragged. The default value is no;

Scrollable: determines whether to scroll when the form does not display the content. The default value is no;

Toolbar: determines whether a toolbar is displayed. The default value is no;

Status: determines whether the status bar is displayed. The default value is no;

Location: whether to display the address bar. The default value is no.

Close your own form: window. Close ();

3. System dialog box:

Warning box: Alert ("XXX ");

Confirmation box: Confirm ("XXX ");

Input box: prompt ("'xxx ")

4. Status Bar

Window. defaultstatus = "xxxxxx"

Wingdow. Status = "xxxxxx"

5. interval and pause:

SetTimeout (); wait for XX milliseconds before execution.

Cleartimeout (); cancel

Setinterval (); wait XX milliseconds before execution

Clearinterval (); cancel

6. History:

Back one page: window. History. Go (-1); or history. Back ()

Previous Page: window. History. Go (1); or history. Forward ()

Ii. Document Object:

Some common attributes of the Document Object:

1. lastmodified: The Last modified Date, which is a string;

2. referrer: the URL of the last position in the browser history;

3. Title: displays text in tags;

4. url: the URL of the currently loaded page.

Change the framework title: top.doc ument. Title = "new page title ";

For example, navigate to the new page:

Document. url = "http://www.baidu.com ";

 

 

Set of document objects:

Anchors: a set of all the anchors on the page;

Applets: Set of all the applets on the page;

Embeds: a set of embedded objects on the page;

Forms: a set of all forms on the page;

Images: a set of all images on the page;

Links: a set of all hyperlinks on the page.

Use document. Links [0] to access the hyperlink;

Use document. Images [0] or document. Images ["imghome"] to access images;

Use document. Forms [0] or document. Forms ["frmsubscribe"] to access the form.

 

 

Iii. Location object:

Hash: If the URL contains #, this method returns the content after;

HOST: the name of the server;

Hostname: equal to host;

Href: the complete URL of the currently loaded page;

Pathname: the part after the host name in the URL;

Port: The request port declared in the URL;

Protocol: the protocol used by the URL;

Search: query string;

Reload the current page: location. Reload ().

 

 

4. navigator object:

Appcodename: return the code name of the browser.

Appminorversion: returns the secondary version of the browser.

Appname: return the browser name.

Appversion: returns the platform and version information of the browser.

Browserlanguage: returns the language of the current browser.

Cookieenabled: returns a Boolean value indicating whether the cookie is enabled in the browser.

Cpuclass: returns the CPU level of the browser system.

Online: returns a Boolean value indicating whether the system is in offline mode.

Platform: returns the operating system platform that runs the browser.

Systemlanguage: return the default language used by the OS.

Useragent: return the value of the User-Agent header sent by the client to the server.

Userlanguage: returns the OS's natural language settings.

Javaenabled (): Specifies whether the browser enables Java.

Taintenabled (): Specifies whether the browser enables data tainting ).

 

 

5. Screen Object

Avaiheight: The height that can be used by the window;

Avaiwidth: The window width that can be used.

Colordepth: the number of digits in the color;

Height: screen height;

Width: the screen width.

Browser object model BOM (Browser Object Mode)

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.