Code for "Bookmark this page"...

Discussion in 'Web Design & Programming' started by blade, May 28, 2007.

  1. blade

    blade GEEK 2.0

    Likes Received:
    0
    Trophy Points:
    0
    I need the javascript code that'll add your Website to a browsers favorites with a click of a button.

    This is the current code I use:
    <a href="javascript:window.external.AddFavorite('WEBSITE', DESCRIPTION')">

    but there are 2 problems:

    1.) It only works for IE, I want one that'll work for Opera and Firefox as well; Safari too if possible

    2.) This code will only add the Website link you specified in the code. I want one that'll bookmark individual pages meaning people can bookmark the current page they're on instead of only being able to bookmark the Website you specified in the javascript code
     
  2. RHochstenbach

    RHochstenbach Administrator Staff Member

    Likes Received:
    26
    Trophy Points:
    48
    Try the following script instead:
    Code:
    <script language="JavaScript1.2" type="text/javascript">
     function CreateBookmarkLink() {
    
     title = "Webpage Title"; 
      // Blogger - Replace with <$BlogItemTitle$> 
      // MovableType - Replace with <$MTEntryTitle$>
    
     url = "Webpage URL";
      // Blogger - Replace with <$BlogItemPermalinkURL$> 
      // MovableType - Replace with <$MTEntryPermalink$>
      // WordPress - <?php bloginfo('url'); ?>
    
    	if (window.sidebar) { // Mozilla Firefox Bookmark
    		window.sidebar.addPanel(title, url,"");
    	} else if( window.external ) { // IE Favorite
    		window.external.AddFavorite( url, title); }
    	else if(window.opera && window.print) { // Opera Hotlist
    		return true; }
     }
    
     if (window.external) {
      document.write('<a href = 
         "javascript:CreateBookmarkLink()");">Add to Favorites</a>'); 
      } else  if (window.sidebar) {
      document.write('<a href = 
        "javascript:CreateBookmarkLink()");">Bookmark Page</a>'); 
     } else if (window.opera && window.print) {	
       document.write('<a href =
         "javascript:CreateBookmarkLink()");">Add Bookmark</a>');
     } 
    </script>
    
    source
     
  3. blade

    blade GEEK 2.0

    Likes Received:
    0
    Trophy Points:
    0
    what part of these do I replace...

    "// Blogger - Replace with <$BlogItemTitle$>"
     
  4. blade

    blade GEEK 2.0

    Likes Received:
    0
    Trophy Points:
    0
    this is only for blogger and wordpress man...
     
  5. Sniper

    Sniper Administrator Staff Member

    Likes Received:
    59
    Trophy Points:
    63
  6. blade

    blade GEEK 2.0

    Likes Received:
    0
    Trophy Points:
    0
    worked for IE and Firefox, not Opera; thanks though
     

Share This Page