Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

One-Time Session Popup


Marc_J

Recommended Posts

Posted

Im using a one-time popup script to make a popup window happen only once per visit to my store, by inserting the following into includes/header.php (at the start after all the checks, before the header table: -

 

<script type="text/javascript">

//JK Popup Window Script (version 3.0)- By JavaScript Kit (http://www.javascriptkit.com)
//Visit JavaScriptKit.com for free JavaScripts
//This notice must stay intact for legal use
//Win Type: Pop Up | Session Only

//Specify URLs to randomly select from and popup/popunder:
//To display a single URL, just remove all but the first entry below:
var popurls=new Array()
popurls[0]="onetimepopup.htm"

function openpopup(popurl){
var winpops=window.open(popurl,"","width=400px,height=365px")
}

function get_cookie(Name) {
 var search = Name + "="
 var returnvalue = "";
 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 == -1)
	 end = document.cookie.length;
  returnvalue=unescape(document.cookie.substring(offset, end))
  }
  }
 return returnvalue;
}

function loadornot(){
if (get_cookie('jkpopup')==''){
openpopup(popurls[Math.floor(Math.random()*(popurls.length))])
document.cookie="jkpopup=yes"
}
}

loadornot()
</script>

 

Which is fine, it pops up my onetimepopup.htm at the correct size on visiting any page in the store. However, it also pops up again when following any link from the page. After that second time, it stops popping up.

 

Any ideas how to fix this so it truly is a one-time popup? I've used the same script on other (non osC) sites without this problem, I assume it's something to do with osC's sessions...???

Posted

No takers?

 

Sorry for the rather early "bump", but the popup is actually a "please don't place orders with this store as it's under development" notice, and as such is rather important right now! So I can't remove it, and it's annoying popping up twice!

 

I submitted a sitemap to google (using chemo's excellent Googel XML Sitemap Feed), so although I had an "index.html" "holder" page to catch casual browsers, google indexed it quicker than I expected and people are finding my store before they are meant to!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...