. 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 the relative path. Any path (../) is 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
, or between . The earlier it is, the earlier it will be executed. Especially if the page code is long, you want to To make the page pop up as early as possible, move it as far forward as possible.
【2. Pop-up window after setting】
Let’s talk about the settings of the 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.
A function openwin() is defined here, and the function content is to open a window. It serves no purpose until it is called. How to call it? Method 1: The window pops up when the browser reads the page; Method 2: The window pops up when the browser leaves the page Window; Method 3: Call with a connection: Open a window Note: Use the "# " is a virtual connection. Method 4: Call with a button:
To avoid the two pop-up windows To cover, use top and left to control the pop-up position so that they do not cover each other. Finally, you can call it using the four methods mentioned above. Note: The names of the two windows (newwindows and newwindow2) should not be the same, or they should all be empty.
[5. Open the file 1.htm in the main window, and the small window page.html will pop up at the same time]
Now we can control the pop-up windows, and the effect will be better. If we add a small piece of code to the pop-up page (note that it is added to the HTML of page.html, not the main page, otherwise...), wouldn't it be cooler if it automatically closes after 10 seconds? First, add the following code to the
Then, use to replace the original in page.html That's it. (Don’t forget to write this sentence! The function of this sentence is to call the code to close the window, and the window will be closed automatically after 10 seconds.)
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