thejackkelly
07-18-2010, 05:38 PM
Hello. When a user first visits /index.html, they select their city. On later visits, I redirect them to their city (ie. /vancouver.html). The script seems to run slowly, and loads the whole /index.html for a second before redirecting. How can I make it faster? I have tried placing my code 1) in the head just below the title, 2) in the head before anything else, 3) in <body onload="...">
function redirect() {
userCity = readCookie ("user_city");
if (userCity)
{
window.location.replace(userCity + ".html");
}
}
Could I use something like if (navigator.cookieEnabled) to run the redirect() function if cookie detected and somehow cancel loading the rest of index.html? (if no cookie, or not enabled, still load index). Or is their a more standard way?
I am a novice and really appreciate any help.
function redirect() {
userCity = readCookie ("user_city");
if (userCity)
{
window.location.replace(userCity + ".html");
}
}
Could I use something like if (navigator.cookieEnabled) to run the redirect() function if cookie detected and somehow cancel loading the rest of index.html? (if no cookie, or not enabled, still load index). Or is their a more standard way?
I am a novice and really appreciate any help.