w3c-webmob / installable-webapps

Use cases and requirements for installable web apps
43 stars 13 forks source link

document old bookmarking APIs #10

Open marcoscaceres opened 10 years ago

marcoscaceres commented 10 years ago

http://stackoverflow.com/questions/3024745/cross-browser-bookmark-add-to-favorites-javascript

marcoscaceres commented 10 years ago

Microsoft used window.external.AddFavorite()

window.external.AddFavorite(location.href, document.title);
marcoscaceres commented 10 years ago

In versions of Internet Explorer prior to 10, Microsoft used to provide a AddFavorite method to allow bookmarking. According to Microsoft's documentation, AddFavorite used to prompt "the user with the same dialog box that is displayed when the user selects Add to Favorites from the Favorites menu." AddFavorite took a URL and an optional title as a an argument:

window.external.AddFavorite(location.href, document.title);

As AddFavorite() is deprecated, in newer version of IE the method fails silently when called.

As a security feature, AddFavorite() had to be "called as a response to a user-initiated action, such a [sic] mouse click. If called from a different context, such as the onload event of the body element, the AddFavorite method fails silently." In addition, calling the "method with a file:// or javascript: URL [returned] a Permission Denied error."

When the value of title was in error, or missing, the URL was used instead. Internet explorer used to use the title of the document as the file name for the favorite on the file system. This meant that IE had to strip out things like "\", "*", and other characters not allowed in file names on the file system.

marcoscaceres commented 10 years ago

Mozilla also had an API that resembled a bookmarking API (The window.sidebar API). However, the scope of that API was more extensive than just bookmarking (allowing for the creation of custom sidebar UIs), so we've excluded it from the discussion. For details, see "Creating a Firefox sidebar extension".