How to create a bookmark in HTML
Many website designers and administrators would like to give their website visitors the possibility to bookmark a page in order to save it for future reference. A similar feature can’t be created by means of HTML only. In the below example we will show you how to add a link to your website which only needs to be clicked by your visitors in order to add the specific page to the bookmarks. Please make sure this feature doesn’t work when testing it locally. A server is needed (the website needs to be live) to properly test it
First, place the following script within the <head></head> section:
<script type="text/javascript">
$(document).ready(function() {
$("#bookmark").click(function() {
if (window.sidebar) {
window.sidebar.addPanel(location.href,document.title,"");
} else if(window.external) {
window.external.AddFavorite(location.href,document.title); }
else if(window.opera && window.print) {
this.title=document.title;
return true;
}
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#bookmark").click(function() {
if (window.sidebar) {
window.sidebar.addPanel(location.href,document.title,"");
} else if(window.external) {
window.external.AddFavorite(location.href,document.title); }
else if(window.opera && window.print) {
this.title=document.title;
return true;
}
});
</script>
Second, create the bookmark link within the <body></body> section:
<a id="bookmark" href="#" rel="sidebar" title="bookmark">Bookmark me!</a>
Live example
<a id="bookmark" href="#" rel="sidebar" title="bookmark">Bookmark me!</a>