2017-10-09 64 views

回答

2
<a id="bookmarkme">Add Bookmark</a> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
<script type="text/javascript"> 
    //Function for add bookmark this page 
    $(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>