Determine that the webpage window appears only once Based on the cookie

Source: Internet
Author: User

This is the JS Code based on the cookie. It is collected from the Internet and is not tested in multiple browsers. The webpage window in IE is only displayed once.


1. Add the following code to the head section of the webpage.

<SCRIPT language = "JavaScript">
Function openpopup (){
Window. open ('HTTP: // /')
Function get_cookie (Name ){
Var search = Name + "="
Var returnvalue = "";
If (document. cookie. length> 0 ){
Offset = document. cookie. indexOf (search)
If (offset! =-1 ){
Offset + = search. length
End = document. cookie. indexOf (";", offset );
If (end =-1)
End = document. cookie. length;
Returnvalue = unescape (document. cookie. substring (offset, end ))
Return returnvalue;
Function loadpopup (){
If (get_cookie ('popped') = ''){
Openpopup ()
Document. cookie = "popped = yes"

2. Put the red code in the following code in the body, as follows.

<BodyOnunload = "loadpopup ()">


<SCRIPT language = "JavaScript"> function openpopup () {window. open ('HTTP: //')} function get_cookie (Name) {var search = Name + "=" var returnvalue = ""; if (document. cookie. length> 0) {offset = document. cookie. indexOf (search) if (offset! =-1) {offset + = search. lengthend = document. cookie. indexOf (";", offset); if (end =-1) end = document. cookie. length; returnvalue = unescape (document. cookie. substring (offset, end)} return returnvalue;} function loadpopup () {if (get_cookie ('popped') = '') {openpopup () document. cookie = "popped = yes" }}</SCRIPT> <body onunload = "loadpopup ()"> <br/> <center> If the effect cannot be displayed, press Ctrl + F5 to refresh the page. For more webpage code: <a href = 'HTTP: //'target = '_ blank'></a> </center>

Tip: the code can be modified before running!

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

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: and provide relevant evidence. A staff member will contact you within 5 working days.