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'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
 
As far as I know, if you want to use JavaScript to redirect, the only way I can think of is to trigger a Javascript function using the onLoad=&quot;somefunction()&quot; command in the <body> line. However, the command won't execute until the page is completely loaded. In this case it's the page that you want the user to bypass. You're probably going to need the movie page to be a cgi page like ASP that examines a cookie on the client computer then redirects accordingly. However, cookies are only specific to computers and not users. If you want your website to identify a user then redirect accordingly, you're going to need a login page that examines the login information, looks up the user in a SQL database, determines if the user has been there before and if not, send the user to the movie page and update the record in the database to show a first visit. The next time the user logs in, the examination will show that the user has been there and redirect to another page before loading the HTML of the movie page.

ToddWW
 
You can do the same by writting

<META HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;8;URL=mypage.html&quot;>

after the <head> tag. Then it will automatically redirect the current page after the time specified by

CONTENT=&quot;8...

(here it is 8 sec)...

 
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 &quot;redirects&quot;, 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top