Js popup box only plays once after two modifications of of

  • 2020-03-29 23:59:59
  • OfStack

Pop-up box only play once, see the net also write a lot, but really can take over with few. The following is the code after I modified, for reference.

This code is controlled by using cookie. Firstly, use cookie to make the browser remember that the page has been opened once. If the page has been opened again, it will not be opened if the page is referenced again. Once the browser is closed, the cookie file holding the record is deleted. So if you close the browser and open it again, the pop-up window will appear again, ensuring that only one window is opened on top of the original window.
 
<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> 

Related articles: