• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9641
  • Last Modified:

Can firefox/Mozilla create a bookmark like window.external.AddFavorite(url,title) in IE

Perhaps using XUL or something?

I do not wish to bookmark current page but to create a bookmark with a url I choose.

The users may allow security overides.

Michel
0
Michel Plungjan
Asked:
Michel Plungjan
  • 5
  • 3
  • 2
  • +2
1 Solution
 
archrajanCommented:
0
 
Michel PlungjanIT ExpertAuthor Commented:
No, I do not mean bookmarklets.
I mean using script (xul?) to create a bookmark in the user's bookmark list.
0
 
davidlars99Commented:
this should work...


<html>
<head>
<script language=Javascript>

function addToFavorites() {
     if (document.all){
          window.external.AddFavorite(document.location.href, document.title);
     }else{
          var ea = document.createEvent("MouseEvents");
          ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
          var eb = document.getElementsByTagName("head")[0];
          eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
          eb.dispatchEvent(ea);
      }
}

</script>
</head>
<body>

<a href="javascript:void()" onclick="addToFavorites();">Add to Favorites</a>

</body>
</html>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dakydCommented:
davidlars, never seen that before ... does that use the native Java somehow?

I found an alternative version, not sure that it's necessarily better or worse, just another option.  It'll give you a prompt, but should do the trick.  The only thing I found was that I needed to test online for it to work ... so, here's one I posted: http://www.freewebs.com/dakyd/ee/bookmark.html.  Hope it helps.

<html>
<head>
<script type="text/javascript">
function addBookmark(title,url) {
  if (window.sidebar)
  {
    window.sidebar.addPanel(title, url,"");
  }
  else if( document.all )
  {
    window.external.AddFavorite( url, title);
  }
  else
  {
    return true;
  }
}
</script>
</head>

<body>
<a href="#" onclick="addBookmark('My Page', window.location.href); return false;">Bookmark this Page</a>
</body>
</html>
0
 
Michel PlungjanIT ExpertAuthor Commented:
COOL!!!

Can you extend the first one to bookmark another page davidlars?

I like the second one!!!
0
 
Michel PlungjanIT ExpertAuthor Commented:
Actually the second does NOT do it. It adds a bookmark that opens in the sidepanel.
0
 
davidlars99Commented:
nevermind, it doesn't work for windows platform I guess...  :o)
0
 
Michel PlungjanIT ExpertAuthor Commented:
Yes it does, David, but how do I feed it the url I want to bookmark. It only bookmarks current page
0
 
dakydCommented:
*smacks self on forehead*

I didn't even click on the bookmark once I created it, I didn't realize it was possible to open up pages in the sidebar like that.  Sorry 'bout that Michel, looks like I'm 0 for 1 today.
0
 
davidlars99Commented:
>  Yes it does, David, but how do I feed it the url I want to bookmark. It only bookmarks current page

where does it keep bookmarks on windows platform..?
0
 
Michel PlungjanIT ExpertAuthor Commented:
C:\Documents and Settings\<userName>\Application Data\Mozilla\Profiles\<profilename>\<randomname>.slt\bookmarks.html
0
 
ee_ai_constructCommented:
Question answered by asker or dialog deemed valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now