. 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.
Parameters Explanation: end of js script
[3. Use functions to control pop-up windows] The following is a complete code .
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]
Add the following code to the
area of the main window:
Join the area:
open.
[6. Timing closing control of pop-up windows]
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
area of the page.html file:
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.)
【7. Add a close button in the pop-up window】