How to change Var value?

wxdqz

New Member
I'm trying to change the value of a variable in a simple popunder script. currently if you set the value of:

var once_per_session=0

to "0" as shown here the page will generate a popunder window every time it is loaded and if you set it to "1" it will load the window only once per session.

What I would like to do is let the user decide if they want to see popunder windows or not so I want let them to be able to either click a link or submit button or something that will set the "once_per_session" variable to "1" if they click it.

So far I have tried forms and links and even forms and links that submit to a funtions and if then statements but I have not been able to change the value of the variable. I'm probably doing something wrong but I just can't seem to figure it out. Does anyone have an idea of what I can to do to make this work?????

Thanks in advance!!!

Below is the entire script I'm working with:



<HTML>
<HEAD>
<TITLE> Pop Under </TITLE>

<SCRIPT LANGUAGE="JavaScript">

//specify page to pop-under
var popunder="http://yahoo.com"

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=0

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('popunder')==''){
loadpopunder()
document.cookie="popunder=yes"
}
}

function loadpopunder(){
win2=window.open(popunder,"",winfeatures)
win2.blur()
window.focus()
}

if (once_per_session==0)
loadpopunder()
else
loadornot()

</script>

</HEAD>

<BODY>
<H1>Load Pop Under</H1>
</BODY>
</HTML>
 
Back
Top