Example 001 open a new window display AD message Instance descriptionThis example pops up an ad dialog box each time the window is loaded. Technical EssentialsThis example mainly applies the JavaScript window object.
Common Methods for Window objects
| Method |
Description |
| Alert () |
Pop up a warning dialog box |
| Confirm () |
Displays the specified string in the confirmation dialog box |
| Prompt () |
Pop up a prompt dialog box |
| Close () |
Close the referenced window |
| Focus () |
Place the referenced window in front of all open windows |
| Open () |
Opens a new browser window and displays the document referenced by the URL or name, and sets the properties of the Create window |
| Resizeto (x, y) |
Set the size of the window |
| Resizeby (offsetx,offsety) |
Sets the size of the window according to the specified amount of displacement |
Use the Open () method of JavaScript to open the browser window.The syntax for opening Windows using the Window object is formatted as follows.
Windowvar = window.open (url,windowname,location);
The parameters are described as follows:1.WindowVar: Handle to the currently open window. 2.url: The URL of the target window. 3.windowname:window: The name of the object. 4.location: Set the window properties.
Optional parameters for setting the window properties
| Properties |
Description |
| Width |
Width of window |
| Height |
Height of window |
| ScrollBars |
Whether scroll bars are displayed |
| Resizable |
Sets whether window size is fixed |
| Toolbar |
browser toolbar, including back and forward buttons, etc. |
| MenuBar |
The menu bar, which generally includes files, edits, and other items |
| Location |
The locator area, also called the Address bar, is the browser text area where you can enter a URL |
| Direction |
Update Information button |
implementation Process(1) First create a page to pop up the ad message, and add the advertised information to the page. new.html
(2) on the index.html page, write the JS code implementation function
Index.htmlNote: The content of the style tag is the knowledge of CSS, and we focus on the content within the script tag. So this example of ours is done.
JavaScript Effects Instance 001-Open a new window to display ad information