Skip to content

Instantly share code, notes, and snippets.

@apphp-snippets
Created May 22, 2012 17:01
Show Gist options
  • Select an option

  • Save apphp-snippets/2770274 to your computer and use it in GitHub Desktop.

Select an option

Save apphp-snippets/2770274 to your computer and use it in GitHub Desktop.
Most today's web browsers like Firefox (Ctrl+D), Opera (Ctrl+T) and IE (Ctrl+D) provide a keyboard shortcuts to enable users bookmark their favorite pages. But if you want to provide your visitors with a "Bookmark this page" link they can click you may us
<script type="text/javascript">
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */
function CreateBookmarkLink(){
var title = document.title;
var url = document.location.href;
if(window.sidebar){
/* Mozilla Firefox Bookmark */
window.sidebar.addPanel(title, url, "");
}else if(window.external){
/* IE Favorite */
window.external.AddFavorite(url, title);
}else if(window.opera && window.print) {
/* Opera Hotlist */
alert("Press Control + D to bookmark");
return true;
}else{
/* Other */
alert("Press Control + D to bookmark");
}
}
</script>
<a href="javascript:CreateBookmarkLink();">Add to Favorites/Bookmark</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment