What is a BOM
The BOM is an abbreviation for the browser object model.
BOM provides an object that is independent of the content and interacts with the browser window
Because the BOM is primarily used to manage the communication between Windows and Windows, its core object is window
A BOM is composed of a series of related objects, and each object provides many methods and properties that tell the thread how to manipulate the object
Global functions:
JS is based on objects, but there are functions that are not encapsulated in objects.
dialog box
Alert (str)-pop-up message dialog box (there is a OK button in the dialog box)
Confirm (str)-Popup message dialog box (contains a "OK" button and "Cancel" button)
Prompt (Str,defaultvalue)-Pop-up Message dialog Box (dialog box contains a "OK" button, "Cancel" button and a text input box), due to different browser implementation, if there is no second parameter (the default value in the text box), it is also best to provide an empty string
Status bar
Window.defaultstatus Property--Changes the default display of the browser status bar (when there is no other display in the status bar), the area at the bottom of the browser is called the status bar, which is used to display information to the user
Window.status Property--temporarily changes the display of the browser status bar
Time Wait and interval function
SetTimeout ()--executes the specified code after pausing the specified number of milliseconds
Cleartimeout ()--cancels the code that the specified settimeout function will execute
SetInterval ()--interval Specifies the number of milliseconds to execute the specified code continuously
Clearinterval ()--cancels the code that the specified setinterval function will execute
The settimeout and SetInterval methods have two parameters, the first parameter can be either a string or a function reference, the second parameter is the interval of milliseconds, and their return is a numeric ID that can be used for the corresponding clear method
var tid = setTimeout ("Alert (' 1 ')", +); alert (tid); Cleartimeout (TID) ;
Window object
Conceptually, we think of window as a container that can host visual entities. The API of the Window object tells the thread how to manipulate it. Note that window can be omitted without writing.
Form Control
Moveby (x, y)-Moves the form's x pixels horizontally from the current position, moves the form y pixels vertically, X is negative, moves the form to the left, Y is negative, and moves the form up
MoveTo (x, y)-Moves the upper-left corner of the form to the (x, y) point relative to the upper-left corner of the screen, and when a negative number is used as a parameter, the form moves out of the visible area of the screen
Resizeby (w,h)--relative to the current size of the form, the width adjusts to w pixels and the height of h pixels. If the argument is negative, the form is scaled down, and the form is enlarged instead
Resizeto (w,h)--Adjust the form width to w pixels and height to h pixels
Form Scroll Axis control
ScrollTo (x, y)--if there is a scroll bar in the form, move the horizontal scroll bar to a position relative to the form's width of x pixels, and move the vertical scroll bar to a position relative to the form's Y-pixel height
Scrollby (x, y)-if there is a scrollbar, move the horizontal scroll bar to the position of x pixels relative to the current horizontal scroll bar (that is, move the X-pixel to the left), and move the vertical scroll bar to a position relative to the current vertical scrollbar height of y pixels (that is, move the Y-pixel down)
Form Focus Control
Focus ()--Causes the form or control to get focus
Blur ()--in contrast to the focus function, causes the form or control to lose focus
New Form
Open ()--Opens (pops up) a new form
Close ()--Close the form
Opener Property--a reference to the parent form in a new form, meaning "opener" in Chinese
Window.Open method Syntax
window.open (URL, name, features, replace);
child window with parent window
Only the window that is opened by itself and using the Window.Open method can be accessed by JavaScript, and the window opened by the Window.Open method accesses the parent window through the Window.opener property. In the opener window, you can access the open window by the return value of the window.open Method!
Framework
Conceptually, a framework is a container that can host windows and indirectly becomes a container for visual entities.
Window.frames collection: In a frameset or page containing an IFRAME tag, the Frames collection contains a reference to a window in a frame
alert (frames.length); // number of frames alert (frames[0].document.body.innerhtml); // use subscript to get a reference directly to a window in the frame // not only can you use subscript, you can also use the Name property of the frame tag Alert (frames["frame1"].document.title);
You can also use an ID in a frameset to get a reference to a child window
var frame1 =document.getelementbyid ("frame1"); // This just gets the label var frame1win = Frame1.contentwindow; // The Contentwindow of the Frame object contains a reference to the window // You can also get a reference to the document in the frame directly var framedoc = frame1.contentdocument; alert (framedoc); // but IE does not support contentdocument properties
Document Object
The HTML document itself is referenced.
getElementById ("CANVAS") returns an object referenced by an element
Write () output to the browser
Canvas
GetContext ("2d") returns a context in which a method in the context tells the thread how to draw (on this canvas).
BOM Browser object model and API detailed