| | |
Scripting an add bookmark link in Firefox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2006
Posts: 2
Reputation:
Solved Threads: 0
Hello everyone - new member here!
I have a javascript function for creating an 'add bookmark' link on my pages. For firefox it uses window.sidebar.addPanel to add the bookmark
To call it I use
The problem lies in the firefox part. A page bookmarked with this function opens in the firefox sidebar. (perhaps unsurprisingly given the name of the method).
Anyone know a way to prevent this or a function that does the job better ? windows.sidebar.addPanel is the only way I know of scripting an add bookmark link in Firefox
I'm using Firefox 1.5.0.3
Jamie
I have a javascript function for creating an 'add bookmark' link on my pages. For firefox it uses window.sidebar.addPanel to add the bookmark
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function addBookmark(title, url) { if (window.sidebar) { // firefox window.sidebar.addPanel(title, url,""); } else if( document.all ) { //MSIE window.external.AddFavorite( url, title); } else { alert("Sorry, your browser doesn't support this"); } }
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="javascript:addBookmark('astro','http://www.astroman.com')>Add bookmark</a>
Anyone know a way to prevent this or a function that does the job better ? windows.sidebar.addPanel is the only way I know of scripting an add bookmark link in Firefox
I'm using Firefox 1.5.0.3
Jamie
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
That's the way it is supposed to work. Actualy, USERS are supposed to add their own bookmarks; it's not something a site should be doing.
However, a web-search reveals this page as the very first result.
However, a web-search reveals this page as the very first result.
•
•
Join Date: May 2006
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by tgreer
That's the way it is supposed to work. Actualy, USERS are supposed to add their own bookmarks; it's not something a site should be doing.
However, a web-search reveals this page as the very first result.
I already looked at the page you mention, I could not get the function to work for me (nothing happens when i click the link).
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script> function addBookmarkForBrowser() { 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> <a href="javascript:addBookmarkForBrowser();">Add to Favorites</a>
does anyone have any idea why? does it work for you?
Jamie
•
•
Join Date: Aug 2004
Posts: 49
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by kincaid
if (document.all)
{
window.external.AddFavorite(document.location.href, document.title);
You should be testing for window.external not for document.all in the if statement since that is the feature you require to use not the one you are currently testing.
With Firefox you can add to the sidebar but not to the bookmarks. To add to bookmarks in Firefox without selecting the bookmarks menu your visitor must press CTRL-D (similarly the only way to do it in Opera is CTRL-T).
![]() |
Similar Threads
- Add your site to link exchange (Relevant Link Exchanges)
- add you link free (Relevant Link Exchanges)
- Bookmark function in mozilla firefox (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: inputtext help
- Next Thread: problem with getElementById
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n






