I want to direct the user to a page (usermenu.html) if upon entering
index.html there is a cookie set on the user's machine. The 'login' cookie
contains the user's id (username).
I'm calling scripts on loading as:
<body onload="initIndex();killAll();setLogin('visitor'); ">
Where killAll kills any existing cookies and setLogin sets a cookie with a
given identifier. initIndex() is
function initIndex () {
lValue = getCookieValue('login');
if (!lValue) {return;}
l_array = lValue.split("}");
username = l_array[3];
if (username == 'visitor' || username == 'guest') {return;}
else {setLogin(username);
window.location = './usermenu.html';
}
}
What is happening that I don't understand is that if I enter the page with a
non-visitor or non-guest cookie it sets the login cookie with the username,
then returns to the onload= line, kills the new cookie, sets a 'visitor'
cookie, and then launches the usermenu with the window.location directive.
Why does it return to the onload= command string before redirecting via
window.location?
TIA for your assistance,
--
Ed Jay (remove 'M' to reply by email)
Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info