Home > Web Front-end > JS Tutorial > body text

Detailed explanation of window.open parameters with examples_Basic knowledge

WBOY
Release: 2016-05-16 17:32:38
Original
1339 people have browsed it

1. window.open() support environment:

JavaScript1.0 /JScript1.0 /Nav2 /IE3 /Opera3

2. Basic syntax of winddown.open:

window.open(pageURL,name,parameters)

Among them:

pageURL is the sub-window path
name is the sub-window handle
parameters is the window parameters (each parameter is separated by a comma)

3. Winddown.open example:

Copy code The code is as follows:

<SCRIPT><br><!-- <BR>window.open('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no, location=no, status=no')<BR>//Write in one line<BR>--><br></SCRIPT>

After the script is run, page.html will be opened in a new window with a width of 100, a height of 400, 0 pixels from the top of the screen, 0 pixels from the left of the screen, no toolbar, no menu bar, and no scrolling. Bar, not resizable, no address bar, no status bar. Please compare.

The above example involves several commonly used parameters. In addition, there are many other parameters, please see 4. 4. Various parameters

Where yes/no can also use 1/0; pixelvalue is a specific value in pixels.


Parameters|Value range|Description

alwaysLowered|yes/no|The specified window is hidden behind all windows
alwaysRaised|yes/no|The specified window is suspended above all windows
depended|yes/no|Whether it is closed at the same time as the parent window
directories|yes/no|Whether the directory bar of Nav2 and 3 is visible
height|pixelvalue|Window height
hotkeys|yes/no|Set a safe exit hotkey in a window without a menu bar
innerHeight| pixelvalue|Pixel height of the document in the window
innerWidth|pixelvalue|Pixel width of the document in the window
location|yes/no|Whether the location bar is visible
menubar|yes/no|Whether the menu bar is visible
outerHeight|pixelvalue|Set the pixel height of the window (including decorative borders)
outerWidth|pixelvalue|Set the pixel width of the window (including decorative borders)
resizable|yes/no|Whether the window size is adjustable
screenX|pixelvalue|The pixel length of the window from the left edge of the screen
screenY|pixelvalue|The pixel length of the window from the upper edge of the screen
scrollbars|yes/no|Whether the window can have a scroll bar
titlebar|yes/no |Whether the window title bar is visible
toolbar|yes/no|Whether the window toolbar is visible
Width|pixelvalue|The pixel width of the window
z-look|yes/no|Whether the window floats above others after it is activated Above the window

【1. The most basic pop-up window code】

Actually the code is very simple:

Copy code The code is as follows:




Because it is a piece of javascripts code, they should be placed between the tag and . are effective for some older browsers. In these old browsers, the code in the tag will not be displayed as text. Develop this good habit.

Window.open('page.html') is used to control the pop-up of a new window page.html. If page.html is not in the same path as the main window, the path should be stated in front, the absolute path (http:// ) and relative paths (../) are available. You can use either single quotes or double quotes, just don't mix them.

This piece of code can be added anywhere in the HTML, between and

, and between . The earlier it is, the earlier it will be executed, especially if the page code is long. , and if you want the page to pop up earlier, put it as far forward as possible.

【2. Pop-up window after setting】

Let’s talk about the settings of pop-up windows. Just add a little more to the code above.
Let’s customize the appearance, size, and pop-up position of this pop-up window to suit the specific conditions of the page.


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]

Parameter explanation:

js script starts;
window.open command to pop up a new window;
'page.html' pop-up window file name;
'newwindow' pop-up The name of the window (not the file name) is optional and can be replaced by an empty '';
height=100 window height;
width=400 window width;
top=0 pixel value from the top of the screen to the window ;
left=0 The pixel value of the window from the left side of the screen;
toolbar=no whether to display the toolbar, yes to display;
menubar, scrollbars represent the menu bar and scroll bar.
Resizable=no whether to allow changing the window size, yes is allowed;
location=no whether to display the address bar, yes is allowed;
status=no whether to display the information in the status bar (usually the file has been opened ), yes is allowed;
js script ends

【3. Use functions to control pop-up windows】

The following is a complete code

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!