最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window sidebar addPanel not work in firefox - Stack Overflow

programmeradmin3浏览0评论
<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.

<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.

Share Improve this question asked Oct 10, 2013 at 7:36 Bubble BubBubble Bub 7015 gold badges12 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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

<a href="http://stackoverflow." title="Stack Overflow" rel="sidebar">Bookmark me</a>
发布评论

评论列表(0)

  1. 暂无评论