Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect question ...

Status
Not open for further replies.

scruples

MIS
Jun 24, 2003
4
0
0
US
I posted this earlier, wondering if someone would be nice enough to write the could for me ;)

Original question:
I'm designing a webpage, and need some script help ...

My page has a starting page (index.html) with an intro movie, I want to have it so that the first time visitors come to the page, they just go normally to index.html, but after the first time, I want them to skip past that and go straight to the actual main page for the site (index2.html). Unfortunately, I have no idea how to do this.

scruples

And the reply that explained what I need:
You should be able to set a cookie with JavaScript that will remain in memory for a specified period of time. This script should first check if the cookie is already present and if it is not, then set it and let the user view the movie.

If the cookie has already been set then the script should send the user to the next page immediately.

This script should consist of top-level code written in the document header so that it executes before the rest of the document is loaded. Users may notice an extra flicker as the page "redirects", but the effect should be negligible.

I don't have time to write the code for this now. If I get a spare moment I may tackle it later. Otherwise maybe somebody else will give it a shot.

-Petey

Anyone who has time, I would greatly appreciate the code ...

Thanks,
scruples
 
Here is the code for something similar that I did... This code will only set the cookie though.
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
function setCookie(NameOfCookie, value, expiredays) 
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + &quot;=&quot; + escape(value) + 
((expiredays == null) ? &quot;&quot; : &quot;; expires=&quot; + ExpireDate.toGMTString() + &quot;; path=/&quot;);
window.location = &quot;[URL unfurl="true"]http://www.yourpage.com&quot;;[/URL] //edit this line
}
</script>
</head>
<body onLoad=&quot;setCookie('name', 'value', '90')&quot;> <!--edit this line-->
</body>
</html>

Hope that helped... For information about reading the cookie go to Most of the code for the above script came from there...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top