Forum Moderators: open
We have a client section that sits behind a veyr easy password scheme. All it requires is the same password from everyone to get in. But then it redirects to the welcome page, no matter what. How do I get it to redirect to the page they were trying to get to?
Here's the code:
<SCRIPT LANGUAGE="JavaScript">
<!--
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires)? "; expires=" + expires.toGMTString() : "") +
((path)? "; path=" + path : "") +
((domain)? "; domain=" + domain : "") +
((secure)? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin!= 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path)? "; path=" + path : "") +
((domain)? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}
function AddCounter() {
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var visits = getCookie("counter");
if (!visits) {
visits = 1;
} else {
visits = parseInt(visits) + 1;
}
setCookie("counter", visits, now);
window.location="http://example.com/support/support_welcome_page.htm";
}
// -->
</SCRIPT>
It's right at the bottom:
window.location="http://example.com/support/support_welcome_page.htm";
But I think Kate82 is wanting to redirect the user to 'whatever' page the user was trying to get to, before being directed to the password entry page(?)
It looks like your AddCounter() function is what controls things, it kinda depends where you are calling this function from, but it may be possible to simply pass the Destination Page to this function....
function AddCounter(DestPage) { And then in the last line, set the window.location to this value, instead of the fixed 'support_welcome_page.htm' as you currently have....
window.location = DestPage;
And then, wherever you call this function (on another page) you pass the URL of the page you want to go to:
AddCounter('/support/pageiwanttogoto.htm');
AddCounter(location.href); // The current page But if you are jumping from page to page, you may need to set your destination page in a Cookie or something and check for that Cookie when you eventually want to get to your intended page.