MozillaZine

javascript for bookmarking a site/page

User Help for Mozilla Firefox
MarkHawaii
Guest
 

Post Posted February 25th, 2007, 10:51 am

I used this script:

function addBookmark(url, title)
{
if (!url) url = location.href;
if (!title) title = document.title;

if (window.external)
window.external.AddFavorite(url, title)
if (window.sidebar)
window.sidebar.addPanel(title, url, "");
//Opera7+
else if (window.opera && document.createElement)
{
var a = document.createElement('A');
if (!a) return false; //IF Opera 6
a.setAttribute('rel','sidebar');
a.setAttribute('href',url);
a.setAttribute('title',title);
a.click();
}
else
{
return false;
}
}

Worked perfectly in IE6, Opera8,9, FF1.5 and etc. Now I am not sure when, but FF ceased to work, I have 2.0.0.1 installed and I am not sure if it is branch 2 that doesnt work or it stopped working prior to releaseing FF2. This snippet is for FF
if (window.sidebar)
window.sidebar.addPanel(title, url, "");

And it worked.

Do you know how to fix this and have it working for FF as well?
And this is the link I use:
<a href="javascript:void(addBookmark())">Bookmark</a>

Thanks

Guest
Guest
 

Post Posted February 25th, 2007, 11:08 am

It's impossible to add bookmark via JavaScript in Firefox.

Guest
Guest
 

Post Posted February 25th, 2007, 11:50 am

Anonymous wrote:It's impossible to add bookmark via JavaScript in Firefox.


Since when??

Is this documented????

Thanks

Guest
Guest
 

Post Posted February 25th, 2007, 12:06 pm

It has never been possible. It's a security measure. And good one. I'll create my bookmarks myself, thank you.

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 15 guests