Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  116] [ 4]  / answers: 1 / hits: 40350  / 13 Years ago, fri, april 29, 2011, 12:00:00

Is there a way to save the current page as a bookmark (through jQuery or otherwise) when a specific button is clicked?


More From » jquery

 Answers
16
<script language=javascript type=text/javascript>
$(document).ready(function(){
$(a.jQueryBookmark).click(function(e){
e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
var bookmarkUrl = this.href;
var bookmarkTitle = this.title;

if (window.sidebar) { // For Mozilla Firefox Bookmark
window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,);
} else if( window.external || document.all) { // For IE Favorite
window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
} else if(window.opera) { // For Opera Browsers
$(a.jQueryBookmark).attr(href,bookmarkUrl);
$(a.jQueryBookmark).attr(title,bookmarkTitle);
$(a.jQueryBookmark).attr(rel,sidebar);
} else { // for other browsers which does not support
alert('Your browser does not support this bookmark action');
return false;
}
});
});
</script>


This Code is taken from Developersnippets!



/e:



Chrome does not support such actions, since the security level could be broken.


[#92490] Thursday, April 28, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sabinal

Total Points: 144
Total Questions: 112
Total Answers: 107

Location: Ghana
Member since Mon, Aug 22, 2022
2 Years ago
;