How do I add an "Add to Favorites" button or link on my website?

webmaniacgr :

I'm building a website using Drupal. On the header of each page I want to have a single image (custom designed by me) which would act as a custom "Add to Favorites" button. Clicking on the image should add the website's URL to the user browser's favorites (bookmarks). This should work for all browsers, IE7+, FF, Opera, Chrome. I wasn't able to find much information for this online. I suppose that javascript should do the job but I don't have much experience in Javascript :) so I need your help!

iambriansreed :

jQuery Version

$(function() {
  $('#bookmarkme').click(function() {
    if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
      window.sidebar.addPanel(document.title, window.location.href, '');
    } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorite
      window.external.AddFavorite(location.href, document.title);
    } else if (window.opera && window.print) { // Opera Hotlist
      this.title = document.title;
      return true;
    } else { // webkit - safari/chrome
      alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Using Dart / Flutter, How do I add favorites inside a ListViewBuilder?

Flutter, How do I add favorites inside a ListView.builder

how to Add to favorites in android recyclerview?

How do i add a link to this animated button

How do i add my own image to a button that links to another website in HTML & CSS?

How do I add or remove roles on my Discord JS server, through a button click I have on my website or localhost?

How do I add/embed java applications to/in my website?

how can i set a link in website to button

How to add facebook share button on my website?

How do I add a condition to my Grafana link?

I want to add image when I share my website link

Add to favorites in windows phone

add to favorites to a new activity

How do I add a button that will restart both of my counters to 0?

How do I add a button to my JavaFX Table View

How do I add a delete button next to my task list?

How can I add a video to my website that plays when you click a button?

How to add a website link in android through touch button

How can i add hover button to the link

How do i click on a website button?

I have a button that switches the theme of my website how do i make the same button if clicked again to change back to the default Theme?

How do I protect my password on the website?

Can I add a hostname to my website for a domain that I do not own?

how do I link a button to a spinner?

"Add To favorites" does not works with appImages

How do I add a button click event to my own button in Visual Studio C#

How do I add a back button and a forward button in pyqt5 to my QGridLayout

How to add a font size button to my website HTML, JavaScript, & CSS?

How do i add next and previous buttons to my react slideshow website