Add current page to browser bookmarks

4

The code below is working, but the technique is old and probably outdated vis-à-vis the current versions of browsers:

function addFavorite( a, b ) {
  title = document.title;
  url = document.location;
  try {
    // Internet Explorer
    window.external.AddFavorite( url, title );
  }
  catch (e) {
    try {
      // Mozilla
      window.sidebar.addPanel( title, url, "" );
    }
    catch (e) {
      // Opera
      if( typeof( opera ) == "object" ) {
        a.rel = "sidebar";
        a.title = title;
        a.url = url;
        return true;
      }
      else {
        // Unknown
        alert( b );
      }
    }
  }
  return false;
}

Usage:

<a href="#" title="" onclick="addFavorite(this, 'Pressione Ctrl-D para adicionar a página aos seus favoritos');return false;">
    Adicionar aos favoritos
</a>

Question

Is the process in its current form working efficiently or can it be simplified and updated to match the specifications of the current browser versions?

    
asked by anonymous 08.05.2015 / 18:54

1 answer

1

Virtually every function you use still works, but it does not work in all browsers and there is no solution to this, for example Chromium browsers (Google Chrome, Opera, Comodo Dragon, etc.) block javascript access to this method.

You can still use it, and it will work on a portion of browsers, but it is likely that these functions will actually be "disabled" (discontinued).

The probable disuse of these methods, the idea is to make the user himself decide whether or not to add the page to favorites.

Discontinued Methods

  • window.external.AddFavorite has been discontinued since Internet Explorer 10

    Source: link

  • window.sidebar.addPanel is obsolete since Gecko 23 (Firefox technology and SeaMonkey)

      

    Note that window.sidebar.addSearchEngine has not been discontinued

    Source: link

Apparently the only one that rel="sidebar" was the only one not discontinued, the reason is that works differently than other methods , as

21.06.2015 / 05:20