문제

<script>
    function Bookmark() {

        alert(navigator.userAgent);
        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(location.href, document.title, "");
        }
        else if (window.external) { // IE Favorite
            window.external.AddFavorite(location.href, document.title);
        }
        else if (window.opera && window.print) {
            alert("ASAS");
            var e = document.createElement('a');
            e.setAttribute('href', location.href);
            e.setAttribute('title', document.title);
            e.setAttribute('rel', 'sidebar');
            e.click();
        }
    }
</script>

<a href="#" onclick="Bookmark()">Bookmark</a>

I has a script to let user click to bookmark the page. It work ok in IE, but it not work in Firefox24.0 version. It show me error window.sidebar.addPanel is not a function. Any one has idea whats go wrong for the above code. Please help!!! Brilliant thanks.

도움이 되었습니까?

해결책

addPanel was removed from Firefox since v. 23. But you can use markup instead:

<a href="http://stackoverflow.com" title="Stack Overflow" rel="sidebar">Bookmark me</a>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top