The JavaScript authoritative guide: The source of the BOM---the Window object

Source: Internet
Author: User

The BOM is an abbreviation for the browser object model, the browser-based, which provides an API that is independent of the Web content and the interaction between browser forms. The API consists of several objects, because the browser is the host of JavaScript, and therefore, these objects are also known as host objects.


One, timer--interval call and deferred call

1, SetInterval () and Clearinterval () methods implement interval calls (follow bad calls)

setinterval (code,millisec[, "Lang"]): Invokes a function or evaluates an expression according to the specified period (in milliseconds) until Clearinterval () is called or the form is closed. Returns a value that can be passed to Window.clearinterval () to cancel the periodic run of code.

Code: Must be the function to invoke or the code string to run.

Call the function to pass in the function name or create an anonymous function.

Millisec: The time at which the interval must be called. in milliseconds.

Lang: Optional. Used to define an arbitrary number of parameters passed to the function.

To cancel the SetInterval () method call with the Clearinterval () method, you must assign the return value of setinterval to a variable to the clearinterval call.


Results:



2, SetTimeout () and Cleartimeout () methods for deferred invocation

SetTimeout (code,millisec): Used to call a function or evaluate an expression after a specified number of milliseconds, just run code once, do not loop the call, assume that you want to call more than once, use SetInterval () or let code itself call SetTimeout (). The number of references is the same as setinterval.

to cancel the cleartimeout () method call with the cleartimeout () method. You must assign the return value of setTimeout () to a variable to the cleartimeout () call.


Results:


3. Forced purge: There is no built-in method to clear all setinterval () or settimeout () at once, so a circular purge is used:

for (var i = 0; i < i++) cleartimeout (i);


Second, the main interactive operation

1. Alert (MSG): Warning dialog box, MSG is the text string to display. The included HTML is displayed as-is.

2, confirm (MSG): Confirm dialog box, the number of parameters with alert; The method returns True ("OK") or False ("Cancel").

3, Prompt (Msg[,input]): Prompt for the message dialog box, MSG with Alert,input optional. Defines the information that is displayed in the text box, or null if no input is defined. The prompt () method returns the information entered by the user as a string or an integer. Press Cancel button to return null

4, ShowModalDialog (Url[,arg]); Opens a dialog box for a new form type that can load a Web page (but not refresh). The URL is the URL address of the loaded Web page, and Arg is the number of parameters passed to the form. Some browsers prevent this form from popping up by default, and you need to set consent to pop up a new form. The method has a return value.

5. Print (): Prints the current document.


var returned = confirm ("Are you a SB?") "), if (returned) {document.write (" You are Sb<br/> ");} else{document.write ("You are not sb<br/>");} var value = prompt ("How old are You?") ",";d ocument.write ("You Are" +value+ "<br/>"); ShowModalDialog ("http://blog.csdn.net/u011043843");



Third, Form interactive operation

1, window.open (): Open a new browser form or find a named form. Returns a reference to the new form.

Optional values for Features:



2, Window.close ([ARG]): Closes the form, ARG is a reference to the form, and no arg is defined, closes the current form.

3. Window.stop (): Cancels the loading of the document.

4. Get the form reference: Window[index] or Window[name]: Gets the Window object by index or name, such as the following:


5, Window.blur (), and Window.focus (): Causes the form to lose focus and get focus, respectively, and trigger the onblur and onfocus events.


Iv. several new properties in HTML5

1. Window.locationbar.visible: Is a Boolean value that defines whether the address bar is visible

2. Window.menubar.visible: is a Boolean value that defines whether the menu bar is visible

3, Window.personalbar.visible: is a Boolean value. Define whether the personal column is visible

4. Window.scrollbars.visible: is a Boolean value that defines whether the scrollbar is visible

5, Window.statusbar.visible: is a Boolean value. Define whether the status bar is visible

6. Window.toolbar.visible: is a Boolean value that defines whether the toolbar is visible

The JavaScript authoritative guide: The source of the BOM---the Window object

Related Article

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.