How to client-side detect when a page is bookmarked?

前端 未结 4 1876
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 07:32

Is it possible to detect when a page is bookmarked within the browser, using Javascript?

4条回答
  •  渐次进展
    2021-01-14 08:09

    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...

提交回复
热议问题