Is it possible to detect when a page is bookmarked within the browser, using Javascript?
4 Answers
No, AFAIK this is not possible.

- 1,023,142
- 271
- 3,287
- 2,928
-
Nowadays Firefox has some functionality for this, but that may be the only browser. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks/onCreated – ashleedawg May 05 '22 at 00:02
Most browsers will not let you detect when a page is bookmarked because this would be another vector for Browser History Mining exploits.
If malicious code could tell what websites you've used then, for example:
- At best, they'd know things about you that you might wish to keep private.
- They could use that information to target you with embarrassing ads or to target your kids with irresistible ads.
- They could target you with much more effective phishing attacks -- since they'd know services, banks, etc. you use online.
It is for this reason that the HTML spec has long required that:
The actual (history) entries are not accessible from script.
It follows that bookmarks are an even more lasting form of history, so they would not be allowed either.
Indeed whenever side-channel history-mining exploits (like the CSS :visited
vulnerability) became known, the appropriate specs are adjusted and security-conscious browsers move to block the privacy hole.

- 90,639
- 22
- 233
- 295
you could try detect key combinations at least, ctrl+d etc etc

- 11
- 1
-
2In most browsers nowadays, people simply _click_ on a star in the address bar instead of using the keyboard. – Shi Aug 05 '11 at 01:46
I found this question when searching for something similar. Here's how I'm doing it:
When the user uses one of the awesome features of the site I run this code
var bm=confirm("How great is this site? Would you like to bookmark it?");
if (bm==true){
window.external.AddFavorite(location.href,document.title);
// and then don't show this again and record that they bookmarked
}
The beautiful part is I'll keep bugging the user to bookmark the page until they do...

- 4,832
- 3
- 32
- 44
-
6I think you're confusing "beautiful" with "incredibly nasty and annoying". – Francisco Zarabozo May 17 '13 at 07:09
-
@FranciscoZarabozo incredibly annoying for the user, yes, but it was exactly what my client was looking for – Coomie May 20 '13 at 02:22