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>