Javascript back |
|
Up until now I have not been happy with the javascript back function you see on many web pages.They work just fine... As long as javascript is enabled and as long as the surfer has reached the page via another page But if the surfer opened your page in a "new window" or typed in the address in the Address bar, nothing happens and it is a wasted click. So I fixed it Now what you do is give the user a default location to go back to. I usually use the home page as the default location So if for some reason the "back" function does not work it defaults to sending the person to your home page. An example would be... <a href="home.html"
onClick="if (window.history.length)
{
window.history.go(-1);
return false;
}
return true;"
>Back</a>
Please note the above is "wrapped" for readability in practice
it would be one long line...
<a href="home.html" onClick="if (window.history.length){window.history.go(-1);return false;}return true;">Back</a> You of course replace "home.htm" with the desired default page and the word "back" with whatever you want
|
|||||||||||||||