JavaScript special effect instance 001-open a new window to display Advertisement Information
Instance 001 the advertisement information is displayed in a new window. instance Description: each time the window is loaded, an advertisement dialog box is displayed. Technical points this example mainly applies the window object of JavaScript.
Common Methods for window objects
Method |
Description |
Alert () |
A warning dialog box is displayed. |
Confirm () |
The specified string is displayed in the confirmation dialog box. |
Prompt () |
A prompt dialog box is displayed. |
Close () |
Close the referenced window |
Focus () |
Place the referenced window in front of all opened windows |
Open () |
Open the new browser window, display the document referenced by the URL or name, and set the properties of the window to be created. |
ResizeTo (x, y) |
Set the window size |
ResizeBy (offsetx, offsety) |
Set the window size according to the specified displacement |
You can use the open () method of JavaScript to open a browser window. The syntax format of window object opening is as follows.
WindowVar = window.open(url,windowname,location);
Parameters are described as follows: 1. WindowVar: the handle of the window currently opened. 2. url: the URL of the target window. 3. windowname: window: name of the object. 4. location: Set window properties.
Optional parameters for setting window properties
Attribute |
Description |
Width |
Window width |
Height |
Window height |
Scrollbars |
Display scroll bar? |
Resizable |
Set whether the window size is fixed |
Toolbar |
Browser toolbar, including the back and forward buttons |
Menubar |
Menu Bar, which generally includes files, edits, and other entries |
Location |
Location Area, also known as the address bar, is the address area of the browser that can enter the URL |
Direction |
Update information button |
Implementation Process (1) first, create a page for pop-up ad information, and add the ad information to be promoted to the page. New.html
(2)write JS Code implementation functions on the index.html page
Index.html
<Script type = "text/jscript" language = "javascript"> window. open ("new.html", "new", "height = 280, width = 800, top = 10, left = 20, resizable = no, location = no", false ); </script>
Homepage
Note: The content of the style label is css. We focus on the content in the script label. In this way, our instance is ready.