javascript bookmark / favorites issue.

Discussion in 'JavaScript' started by deluxmilkman, Dec 14, 2007.

  1. #1
    I'm trying to make a book mark button the following is what I have.
    It shows the alert, but bookmark nothing.
    (I'm using Mac.)


    
    function bookmark(title, url){
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
    
    window.external.AddFavorite(url,title);
    alert("IE: bookmarked");
    }
    else if(navigator.appName == "Netscape"){
    alert("NETSCAPE: NOT SUPPORTED");
    }else{
    alert("NOT SUPPORTED");
    	}
    }
    
    
     <a href="javascript:bookmark('My title','My url');">Click to Bookmark</a>
    
    HTML:
    When I use the following in function, nothing happens.


    if (window.sidebar) {
    window.sidebar.addPanel(title, url);
    } else if( window.external ) {
    window.external.AddFavorite( url, title);
    }

    Can you help me?
     
    deluxmilkman, Dec 14, 2007 IP
  2. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    It seems to me that the reason that you're not getting the page bookmarked is that you're using a Mac. (What browser are you using?)

    The AddFavorite function is in IE-only - hence the "if Microsoft Internet Explorer" code. You getting the alert, but no bookmark is the correct behavior.
     
    KatieK, Dec 16, 2007 IP
  3. DatR

    DatR Peon

    Messages:
    210
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try this script i use on my one site:

    
    function bookmark(title, url){
    if (document.all)
     window.external.AddFavorite(url, title);
    else if (window.sidebar)
     window.sidebar.addPanel(title, url, "")
    }
    
    Code (markup):
     
    DatR, Dec 17, 2007 IP
  4. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #4
    thank you for good tip
     
    temp2, Dec 18, 2007 IP