Home Web Front-end JS Tutorial Detailed explanation of window.open parameters with examples_Basic knowledge

Detailed explanation of window.open parameters with examples_Basic knowledge

May 16, 2016 pm 05:32 PM
window.open

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

10 jQuery Fun and Games Plugins 10 jQuery Fun and Games Plugins Mar 08, 2025 am 12:42 AM

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

How do I create and publish my own JavaScript libraries? How do I create and publish my own JavaScript libraries? Mar 18, 2025 pm 03:12 PM

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

Load Box Content Dynamically using AJAX Load Box Content Dynamically using AJAX Mar 06, 2025 am 01:07 AM

This tutorial demonstrates creating dynamic page boxes loaded via AJAX, enabling instant refresh without full page reloads. It leverages jQuery and JavaScript. Think of it as a custom Facebook-style content box loader. Key Concepts: AJAX and jQuery

jQuery Parallax Tutorial - Animated Header Background jQuery Parallax Tutorial - Animated Header Background Mar 08, 2025 am 12:39 AM

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the

How to Write a Cookie-less Session Library for JavaScript How to Write a Cookie-less Session Library for JavaScript Mar 06, 2025 am 01:18 AM

This JavaScript library leverages the window.name property to manage session data without relying on cookies. It offers a robust solution for storing and retrieving session variables across browsers. The library provides three core methods: Session

See all articles