Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Add to favorites" with JavaScript in Opera [duplicate]

How to make this work in Opera? I found this piece of code for Opera, but it doesn't work for me:

 function AddToFavorites(title, url) {

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
        return false;
    } 
    else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title); 
        return false;
    }
    else if(window.opera && window.print) { // Opera Hotlist
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.click();
                return false;
    }
 }

The Dragonfly error console is silent, no errors are occuring.

like image 284
Matěj Zábský Avatar asked Dec 31 '22 07:12

Matěj Zábský


1 Answers

If you insist on it, then do it without dynamically generated redundant links:

 <a href="http://real.url.example.com" title="Bookmark me, pleaeease!" 
    rel="sidebar"
    onclick="return !addToFav(this.href,this.title)">

but please, just don't do it.

As Opera user I will be grateful for not pushing that fad – I can easily drag'n'drop tab to bookmarks bar/panel/speedial if I choose to.

like image 162
Kornel Avatar answered Jan 09 '23 16:01

Kornel