PDA

View Full Version : 'Back' and 'Bookmark' Links



Ronald Ng
21st Feb 2004, 06:27 pm
How do you make a link which when clicked will take u back to the previous page? ie. same as the 'Back' button.

Also, how do you make a link which will bookmark the page?

I presume it's some javascript code?

Thanks.

David
21st Feb 2004, 07:06 pm
I'm not entirely sure that I approve of either of these methods. I tend to feel that browser functions should be left to the browser and that the user be in full control but...

The "Back" Link

The "Back" link is very simple:

</div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>HTML </td></tr><tr><td id='CODE'><a href="#" onClick="history.go&#40;-1&#41;">Back</a>
</td></tr></table><div class='postcolor'>

The value -1 refers to the number of pages to go back in the browser history.

If you want the link to be a button, you can do this:

</div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>HTML </td></tr><tr><td id='CODE'><input type=button value="Back" onClick="history.go&#40;-1&#41;">
</td></tr></table><div class='postcolor'>

The "Bookmark" Link

To bookmark the current page with a link, you can use this code:

</div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>HTML </td></tr><tr><td id='CODE'><span style=&#39;cursor&#58;hand;text-decoration&#58;underline;&#39;onclick=&#39;window.external.add Favorite&#40;location.href,document.title&#41;;&#39;>
Click here to add this page to your favorites</span>
</td></tr></table><div class='postcolor'>

Alternatively, if you want the link to bookmark a specific URL (for example, you can bookmark your homepage form any page on your site), use this code:

</div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>HTML </td></tr><tr><td id='CODE'><a href="javascript&#58;window.external.addFavorite&#40;&#39;http&#58;//www.website.com&#39;,&#39;Website Title&#39;&#41;;">
Click here to add the homepage to your favorites</a>
</td></tr></table><div class='postcolor'>