


JavaScript pop-up window window.open usage method and parameter description analysis_Basic knowledge
1. window.open() supported environment:
JavaScript1.0 /JScript1.0 /Nav2 /IE3 /Opera3
2 , Basic syntax:
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 commas)
3. Parameters
Where yes/no can also use 1/0; pixel value is a specific value, in pixels.
Parameter | Value range| Description| |
alwaysLowered | yes/no | The specified window is hidden behind all windows
> Depended | yes/no | Whether to close at the same time as the parent window
Directories | yes/no | Whether the directory bar of Nav2 and 3 is visible
Height | pixel value | Window height
hotkeys | yes/no | in A safe exit hotkey is set in a window without a menu bar
innerHeight | pixel value | pixel height of the document in the window
innerWidth | pixel value | pixel width of the document in the window
location | yes/no | location bar Is it visible?
Menubar | yes/no | Is the menu bar visible?
OuterHeight | pixel value | Set the pixel height of the window (including decorative borders) pixel width of the decorative border
resizable | yes/no | whether the window size can be adjusted
screenX | pixel value | pixel length of the window from the left border of the screen
screenY | pixel value | Pixel length
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 | pixel value | pixel width of the window
z-look | yes/no | whether the window floats on top of other windows after it is activated
Let me take you to analyze its mystery.
[1. The most basic pop-up window code]
In fact, the code is very simple:
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute it ] Because it is a piece of javascripts code , so they should be placed between the . 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 written in front, the absolute path (http Both ://) and relative paths (..
/) are acceptable.
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 window. 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 ]
参数解释:
js脚本结束
【3、用函数控制弹出窗口】
下面是一个完整的代码。
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一: 浏览器读页面时弹出窗口;
方法二: 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:
打开一个窗口
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:
【4、同时弹出2个窗口】
对源代码稍微改动一下:
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可
。最后用上面说过的四种方法调用即可。
注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。
OK?
【5、主窗口打开文件1.htm,同时弹出小窗口page.html】
如下代码加入主窗口区:
加入区:
open即可。
【6、弹出的窗口之定时关闭控制】
下面我们再对弹出的窗口进行一些控制,效果就更好了。如果我们再将一小段代码加入弹出的页面(注意是加入到page.html的HTML中,可不是主页面中,否则...),让它10秒后自动关闭是不是更酷了?
首先,将如下代码加入page.html文件的区:
然后,再用 这一句话代替page.html中原有的
【7、在弹出窗口中加上一个关闭按钮】
呵呵,现在更加完美了!
【8、内包含的弹出窗口-一个页面两个窗口】
上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。
通过下面的例子,你可以在一个页面内完成上面的效果。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Methods to close an open window: 1. Use "window.close" to close the new window; 2. Use "window.location" to redirect; 3. Use "window.blur" and "window.focus"; 4. Use "window. .history" fallback; 5. Use "window.opener".

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).
