Hi,
I need a pop under script completed. I have all the code, but from two different scripts. I need functionality from both scripts combined into one new script. Anyone that knows javascript should be able to complete this task in 5 minutes.
Script #1 loads a random URL from an array and checks to see if a cookie exist and has not expired in last 36 hours, and if no cookie loads a pop under.
Script #2 loads a pop under “onclick” from a submit button.
The script I need:
Make script #1 load from an “onclick” submit button instead of just loading automatically.
SCRIPT 1:
<script type=”text/javascript”>
var popunder=new Array()
popunder[0]=”http://www.yahoo.com”
popunder[1]=”http://www.msn.com”
var winfeatures=”width=1024,height=800,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0″
var popfrequency=”36 hours”
///No editing beyond here required/////
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(){
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],”",winfeatures)
win2.blur()
window.focus()
}
if (popfrequency==”always”){
resetcookie()
loadpopunder()
}
else{
if (get_cookie(‘tcpopunder’)!=parseInt(popfrequency))
resetcookie()
loadornot()
}
</script>
SCRIPT 2:
<script type=”text/javascript”>
function open_win() {
window.open(“http://www.window1.com/”)
window.open(“http://www.window2.com/”)
}
</script>
<form>
<input type=button value=”Open Windows” onclick=”open_win()”>
</form>