PDA

View Full Version : Pop-Under - setTimeout?


vanguys
09-27-2002, 05:09 AM
I am dealing with the following code and I would like to know how to make it so the pop-under window doesn't load for at least two seconds. I've tried various techniques including setTimeout, but my javascript skills are not so good. Any help would be appreciated. Thanks!

<%
'http://jdanish/eduvantage/redirect2.asp?title=title&url=http://www.sprawlwear.com&popunder=http://www.cnn.com

pageTitle = Request("title") '"ITT Technical Institute"
urlToLoad = Request("url")
popunderToLoad = Request("popunder")

%>
<html>
<head>
<title><%=pageTitle%></title>

<%if(Not popunderToLoad = EMPTY)then%>
<script>

//Pop-under window II- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script

//specify URLs to randomly select from and pop-under
var popunder=new Array()
popunder[0]="<%=popunderToLoad%>";

//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=1

var showdelay=2000;


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

function loadpopunder(){
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"Eduvantage","height=608,width=785, location=yes,

menubar=yes, resize=yes, toolbar=yes, resizable=yes, scrollbars=yes", true)
win2.blur()
window.focus()
setTimeout('loadpopunder()',20)
}

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

</script>


<%end if%>
</head>

<frameset>
<frame src="<%=urlToLoad%>">
</frameset>

</html>

jamescover
09-27-2002, 08:13 AM
setTimeout('loadpopunder()',2000)


James
He is risen!!!

vanguys
09-27-2002, 08:50 AM
Thanks! But is the setTimeout being called in the right place? It is acting funny and continually reloads the pop every 2 seconds. Also, the initial pop loads instantly rather than later.

Are there any other options for making this delay the 2 seconds rather than setTimeout?

Please help! Thanks!

jamescover
09-27-2002, 09:20 AM
You code formatting is all messed up, but I extracted just the popunder and ran it like this:


<script>
function loadpopunder(){
win2=window.open("index.html","Eduvantage","height=608,width=785,location=yes,menubar=yes, resize=yes,toolbar=yes,resizable=yes,scrollbars=yes",true);
win2.blur();
window.focus();
}
setTimeout('loadpopunder()',2000);
</script>

Worked as expected.


James
He is risen!!!