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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load another page when back is pressed 1

Status
Not open for further replies.

humbleprogrammer

Programmer
Oct 30, 2002
315
0
0
US
Hello,

Is there a way to load another page when the back button is pressed? I have a Flash intro page, which then leads into the main site. The client doesn't want the Flash intro page to load again if the visitor clicks back, he instead wants another page without Flash to load.

Thanks in advance!
 
You could try and use an allowed referrer script where the flash page or pages would only be viewed in a particular sequence. Thus when the back button is pressed an alert will come up and when clicked will return them to the page of your choice...

Try this out for a possible solution...

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
var allowedreferrer = &quot;if (document.referrer.indexOf(allowedreferrer) == -1) {
alert(&quot;You can only access this page from &quot; + allowedreferrer);
window.location=allowedreferrer;
}
// End -->
</script>


You can set the window.location= to the page desired..

Hope this helps you out,
Brian
 
If you use location.replace to redirect from the intro page that'll do it.
 
Thanks Brian - the referrer works if a link to the Flash page is clicked but it doesn't have any affect if the back button is clicked. Do you know how I can determine if back was clicked and then re-direct them using the referrer?

theboyhope - I would be interested in using the location.replace but how do I first determine if the user clicked back? Can I do something with the history?

Thanks in advance!
 
What I thought you wanted was for the back button to take them back to whatever page they were on before they arrived at the flash intro. Do you want to send them somewhere completely different?

If so, why? The user will have clicked back because they want to go back where they came from. I'd be pretty annoyed if a website redirected me somewhere else in that situation.

Anyway, AFAIK, you can't detect that the back button has been clicked using Javascript.
 
The Flash intro is the 1st page(default) they hit when they go to the site. The client (not my choice) does not want the Flash intro to run again if the user hits back, he instead wants another page to load that looks exactly the same (html version) but without any Flash. I created an HTML version the user goes to if they click on a &quot;home&quot; link within the site but this doesn't solve the back problem.

 
Use drop a cookie on the user's machine when they hit the flash page. Then check for the existence of the cookie every time they hit the flash page, if it's not there display the flash page - if it is, redirect them to the HTML version.

Of course you could always ask your client what happens to the people that want to have another look at the flash page.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]
 
No link is more gratefully used in my opinion than skip flash intro.... Then, people can hit [back] to watch that fabulous bandwidth leprechaun, but if they are so boorish as to want to see actual content, then they can just click the link.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Didn't think about cookies. Great idea! I did ask my client that exact question but he is persistent on having it display only once. After the initial Flash is displayed, he wants the site to load lightning fast, which is the reason he doesn't want the intro to run again. I even suggested a link &quot;display flash intro&quot; for the visitors who do want to view it again but he wouldn't go for it. The intro is under 5 seconds but he still only wants it to run once. So, I always try to offer suggestions but in the end, the client always gets what the client wants.

Anyway, thanks for the cookies suggestion!
 
I agree Edward and the intro does have that famous &quot;Skip Intro&quot; link and is under 5 seconds but sometimes clients request the strangest things. My personal opinion on the subject is - why even have a flash intro if you aren't going to utilize it? But hey, it's his decision. I am not going to argue with him when he is paying for this months bills.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top