JS Pop-up box only play once (two modified) _javascript tips

Source: Internet
Author: User
Pop-up box only play once, see the Internet also write a lot, but really can bring over the use of few. The following is my revised code for reference.

This code is controlled using cookies, first using cookies to let the browser remember that this page has been opened once, if you refer to this page has been opened once, if you refer to the page again will not open. Once the browser closes the browser, the cookie file that saved the record will be deleted. So close the browser and open it again, and the pop-up window will appear, ensuring that only one window is open on the original window.
Copy Code code as follows:

<script type= "Text/javascript" >
var returnvalue = "";
function Openpopup () {
<s:if test= "isalreadygetgift = 0" >
$.colorbox ({inline:true, href: ' #getGiftForm ', innerwidth: ' 650px; ', innerheight: ' 475px; ', onopen:true});
$ ("#getGiftSuccess"). Hide ();
</s:if>
}
function Get_cookie (Name) {
var search = Name + "=";
if (Document.cookie.length > 0) {
offset = document.cookie.indexOf (search);
if (offset!=-1) {
If Cookie exists
Offset + + search.length;
Set index of beginning of value
End = Document.cookie.indexOf (";", offset);
Set index of end of cookie value
if (end = = 10) {
end = Document.cookie.length;
Returnvalue=unescape (document.cookie.substring (offset, end));
}
}
}
Return returnvalue;
}
function Loadpopup () {
if (Get_cookie ("popped") = = "") {
Openpopup ();
Document.cookie= "Popped=yes"
}
}
$ (document). Ready (function () {

Loadpopup ();

});
</script>

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: 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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.