|
Description: |
Hi,
This current javascript does a pop under onclick from a random rotation of urls everytime our users clicks a login submit button. I need it NOT to be random. First time visitor presses onclick button, display url 1. Second time visitor clicks onclick load url 2, and so on up to end of our url list, then repeat. This way it is kind of setup as a "round robin" setup and a user is not show same advertisement every time they login. I'm pretty sure this is done by setting different cookies, but I'm not sure. Here is my current code.
<script type="text/javascript">
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 resetcookie(){
var expireDate = new Date()
expireDate.setHours(expireDate.getHours()-10)
document.cookie = "tcpopunder=;path=/;expires=" + expireDate.toGMTString()
}
function loadornot(){
if (get_cookie('tcpopunder')==''){
loadpopunder()
var expireDate = new Date()
expireDate.setHours(expireDate.getHours()+parseInt(popfrequency))
document.cookie = "tcpopunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
}
}
function loadpopunder(popunder, winfeatures){
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
win2.blur()
window.focus()
}
function open_win() {
var popunder=new Array()
popunder[0]="http://www.yahoo.com"
popunder[1]="http://www.bing.com"
popunder[2]="http://www.ask.com"
popunder[3]="http://www.google.com"
var winfeatures="width=1024,height=800,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"
var popfrequency="always"
if (popfrequency=="always"){
resetcookie()
loadpopunder(popunder, winfeatures)
}
else{
if (get_cookie('tcpopunder')!=parseInt(popfrequency))
resetcookie()
loadornot()
}
}
</script>
|