Bookmark on Firefox

P

Pipp

Hi, this simple code works well to add a bookmark on IE, but it
doesn't work on Firefox
<a href="javascript:window.external.AddFavorite('http://
www.mysite.com','My site is cool');">

Can someone suggest me something ?
 
M

Mad Joe

// Firefox 1.x+, IE4+ and Opera7+

<script type="text/javascript">
<!-- // Begin
function bookmarksite(title,url){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
window.external.AddFavorite(url, title);
}
// End -->
</script>

<a href="javascript:bookmarksite('Page Title',
'http://www.example.com')">Bookmark this site!</a>
 
P

Pipp

On Firefox this opens the bookmark on the sidebar, how to open it on
the main window ?
 
M

Mad Joe

Randy said:
Remove the worthless, non-working, useless comments.

I'm hiding it because of the stupid W3C validators...
While Firefox may support sidebar, it may not be the only browser that
does. But, at least this branch of the if half tests for what you are
using.
Is there a browser (or even a version of Opera) that doesn't support
window.print? And, why aren't you testing for what you really want to use?
IE is far from the only browser that will enter this branch. AOL, for
one, will pass that test but utterly error out on the call to
window.external, and, there is *no* way to add a favorite in AOL via
scripting.

Ask Frankyboy: http://www.dynamicdrive.com/dynamicindex9/addbook.htm
What happens if scripting is disabled? And, what happens, in IE, when an
animated gif is on the page? (Test it).

What if somebody plugs our visitor's ass on 220V and torture him to
death while another jerk is recording the whole event for publishing on
YouTube? Maybe we should build a script which could prevent that sick
possibility to avoid the mess with the law.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top