![]() ![]() |
Moderator Alumni![]() Group: Hall Of Fame
Joined: 1-September 02
Posts: 9,213
From: UK
|
Mar 12 2003, 10:50 PM |
|
|
One of the most common uses for JavaScript is that of redirection, especially where frames are concerned. Unfortunately, the vast majority of JavaScript redirection is poorly done, breaking the browser back button. This simple 'How to...' tutorial shows you the correct code to use for javascript redirection.
JavaScript code for redirection is very widely available, but all too often it makes a classic mistake and so breaks the browser back button. This happens because when the user hits the back button, the browser goes back to where the javascript was (which is now cached and so works super-fast) which sends the browser instantly forward again. The fault lies wherever you see the following code: CODE location.href=
Setting the property of the location.href to a value is a simple method for moving the user, but it means that the back button will take them back to the javascript. Instead the correct code should use the location.replace(); method CODE location.replace(newurl);
The replace method actually does something pretty cool. It takes the current page location in the browser history and replaces it with the new url that you specify in the brackets. The old url that the code was on will no longer be in the browser history, and so the back button will go straight to the page before the one the script was on. Simple, effective and seamless. Some Sample Uses: To break free of framesets from other sites: CODE if (top != self) {
top.location.replace(self.location); } To reload the index page if the current page is not within your frameset: CODE if (top == self) {location.replace('index.htm');}
For more about dealing with Frames and Framed Sites see my article: SEO for Frames and Framed Sites |
||
| Offline | ![]() |
UntestedGroup: Members
Joined: 16-September 03
Posts: 2
From: Leeds
|
Sep 18 2003, 04:00 PM |
|
|
Solved it!
|
||
| Offline | ![]() |
MemberGroup: Members
Joined: 2-October 03
Posts: 10
From: philipines
|
Oct 3 2003, 04:57 AM |
|
|
help pls...!!!
my website working on http://www.mysite.com but if i type http://mysite.com my default web page's doe's not display someby help [/img] |
||
| Offline | ![]() |
MemberGroup: Members
Joined: 2-October 03
Posts: 10
From: philipines
|
Oct 3 2003, 05:00 AM |
|
|
i like them working both http and www
any could give me some idea where i'm mistake |
||
| Offline | ![]() |
|
|
2 Pages 1 2 >
|
|
| Lo-Fi Version | Time is now: 9th February 2010 - 05:56 PM |
| Meet our Moderators: | cre8pc : projectphp : sanity : Black Phoenix : bwelford : EGOL : Ruud : rustybrick : AbleReach : swainzy : joedolson: eKstreme: dazzlindonna : SEOigloo: iamlost : RisaBB |