/    Sign up×
Community /Pin to ProfileBookmark

script works on local computer but not when published

i copied a script that opens a popup once using a cookie. It works perfectly popping up the window if i run it locally by pointing my browser to the file location. After publishing to localhost or web server it does not popup the window. i do remove the cookie between tries. The various software is Window XP pro and IIS 5.1, IE 6.0.2 locally. The server is Windows 2003 with IIS 5.1. I have included the script as i changed it.

<html>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>Free JavaScripts provided by The</title>

<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin
var expDays = 0; // number of days the cookie should last

var page = “elections.html”;
var windowprops = “width=1000,height=700,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes”;

function GetCookie (name) {

var arg = name + “=”;

var alen = arg.length;

var clen = document.cookie.length;

var i = 0;

while (i < clen) {

var j = i + alen;

if (document.cookie.substring(i, j) == arg)

return getCookieVal (j);

i = document.cookie.indexOf(” “, i) + 1;

if (i == 0) break;

}

return null;
}
function SetCookie (name, value) {

var argv = SetCookie.arguments;

var argc = SetCookie.arguments.length;

var expires = (argc > 2) ? argv[2] : null;

var path = (argc > 3) ? argv[3] : null;

var domain = (argc > 4) ? argv[4] : null;

var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + “=” + escape (value) +
((expires == null) ? “” : (“; expires=” + expires.toGMTString())) +
((path == null) ? “” : (“; path=” + path)) +

((domain == null) ? “” : (“; domain=” + domain)) +

((secure == true) ? “; secure” : “”);
}
function DeleteCookie (name) {

var exp = new Date();

exp.setTime (exp.getTime() – 1);

var cval = GetCookie (name);

document.cookie = name + “=” + cval + “; expires=” + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie(‘count’)
if(count == null) {
SetCookie(‘count’,’1′)
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie(‘count’)
SetCookie(‘count’,newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (“;”, offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie(‘count’);
if (count == null) {
count=1;
SetCookie(‘count’, count, exp);

window.open(page, “”, windowprops);

}
else {
count++;
SetCookie(‘count’, count, exp);
}
}
// End –>
</script>

</head>

<body>

<BODY OnLoad=”checkCount()”>

<p>a<center>
<font face=”arial, helvetica” size=”+2″>Your vote has been recorded! Thank you</font>
</center><p>

<!– Script Size: 2.58 KB –>
</body>

</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @RonCaldwell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...