How to eject a notification when a Web page is open, JS code
Source: Internet
Author: User
The following is commonly used some pop-up window code, interested in everyone can try Yo: "1, the most basic pop-up window code"
In fact, the code is very simple:
Because it's a javascripts code, they should be placed in
The code in the label is not displayed as text in the device. To develop this good habit ah. window.open (' page.html ') is used to control the pop-up of the new window page.html if page.html does not
In the same path as the main window, the path, absolute path (http://), and relative path (...) should be specified before. /) are available. Use single quotes and
Double quotes are OK, just don't mix. This piece of code can be added anywhere in HTML, and between can, between
Can also, the more early implementation, especially the length of the page code, but also want to make the page early pop-up as far as possible forward.
"2, after the Set pop-up window"
Let's say a pop-up window setting. Just add something to the code above. Let's customize the appearance of this pop-up window, size, and popup position to fit the page's specifics. Parameter explanation:
"3, control pop-up window with function"
The following is a complete code. ... Any page content ... A function Openwin () is defined here, and the function content is to open a window. There is no use before calling it. How to call it. Method one: Pop-up window when the browser reads the page; Method two: Pop-up window when the browser leaves the page; method Three: Open a window Note: The use of "#" is a virtual connection. Method Four: Use a button to invoke:
"4, pop-up 2 windows at the same time"
Change the source code slightly: to avoid the pop-up 2 window coverage, use top and left to control the pop-up position do not cover each other. And I said it in the last
Four ways to call.
Note: The name of the 2 windows (NewWindows and NewWindow2) is not the same, or simply all empty. Ok.
"5, the main window to open the file 1.htm, while pop-up small Windows page.html"
The following code is added to the main window area: join: Open.
"6, pop-up window of the timing off control"
Below we have some control of the pop-up window, the effect is better. If we add a small piece of code to the bullet
Out of the page (note is added to the page.html HTML, not the main page, otherwise ...), so that it automatically shuts down in 10 seconds is
No, it's cooler.
First, add the following code to the area of the page.html file: Then, replace page.html with this sentence
It's OK. (Don't forget to write this sentence.) The function of this sentence is to call the closing window code, 10 seconds after the self
Closes the window. )
"7, add a Close button in the pop-up window"
Oh, now more perfect.
"8, included pop-up window-one page two windows"
The example above contains two windows, one is the main window and the other is a pop-up window.
With the example below, you can do the above in one page. Open a window to see if the code inside the OpenWindow.document.write () is not standard HTML. Just write more lines in the format
Can. Be sure to pay attention to one more label or one less label will cause errors. Remember to use OpenWindow.document.close () knot
Beam AH.
"9, the Ultimate application-pop-up window of the cookie control"
Recall that the above pop-up window is cool, but there is a little trouble (immersed in joy, must not find
it. For example, if you put the above script in a page that needs to go through frequently (for example, the first page), then each time you refresh the page,
window will pop up once, is not very annoying. Is there a solution to:-(? yes! ;-) Follow me.
We can use cookies to control it.
First, add the following code to the area of the home page HTML: Then, use (notice is not openwin but Loadpop ah.) ) for
To change the main page of this sentence can be. You can try to refresh the page or re-enter the page, and the window
It won't pop up. The real pop-only-once.
Note that the capitalization in the JS script is best kept consistent.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service