add bookmark using javascript, it opens in the sidebar, not in the main window
im using this function:
function add_bookmark(){ var title = "My Title"; var url = "www.myurl.com"; window.sidebar.addPanel(title, url, ""); }
it successfully creates a bookmark but when i click on it, it just opens in the sidebar and not in the main window.
Alla svar (5)
Don't use that function as it selects the "Open this bookmark in the sidebar" feature in Properties for the bookmark. That is the way it works in Firefox and it probably won't ever be fixed. Someone filed a Bug about fixing that in Firefox back in 2004 or 2005, and the Mozilla developers marked it as WONTFIX due to perceived security issues with scripts of that sort.
so there's still no solution for this problem after all. just tell the users to press Ctrl-D instead.
but what probably will be the issues when allowing such scripts, if they can allow scripts to create and open bookmarks in the sidebar, why not allow it to open in the main window?
tnx! ^_^
Sorry, I don't recall what the perceived security issue was. I didn't bookmark that particular Bug report and I couldn't find it an hour ago when I searched for it for this thread. IIRC, that was the exact recommendation in the Bug report, just tell Firefox users to use {Ctrl+D} to Bookmark the page.
6 or 7 years ago I searched the free JavaScript websites, like Dynamic Drive, for "Bookmark the Page" type scripts and found three different scripts, two that worked in IE-only and just one that was labeled for "Netscape". That "Netscape" version was the one that "ticked" the "Open this bookmark in the sidebar" in Firefox.
Bug 305398 - JavaScript sidebar.addpanel should have similar behaviour as adding bookmark manually
Bug 214530 - Need Way to Create Bookmarks From Pages.
Bug 66248 - (AddBookmark) [RFE] Ability for page javascript to add bookmark
A page I had bookmarked kept opening in the sidebar... it was driving me crazy until I found the answer on this forum. Further research led to this thread. I have to ask, if script-based creation of bookmarks is a security risk, why still allow scripts to create bookmarks at all (much less ones that only open in the Sidebar)?
It's not enough to tell users (after the fact!) that they need to bookmark pages from Firefox itself. People are going to see those "Bookmark this page" buttons on websites and click on them...
The developers really need to fix this once and for all.