SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Script to create a bookmark link

    I want to add a link to my site's homepage where viewers can click on a link to automatically "add to favorites" or "bookmark" the page.

    Does anyone know anything about this?


    singersower

  2. #2
    SitePoint Addict CrabbyX's Avatar
    Join Date
    Aug 2004
    Location
    England, UK
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="javascript:window.external.AddFavorite('URL','bookmark text')">Bookmark</a>

    Quick Google does the trick.
    michael.Crabbe

  3. #3
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Woo Hoo!!! Thank you!!!

    I must have not put in the proper keywords for my google search.

    thank you so much!!!

    singersower

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That only works in IE. Clicking on a link to add a bookmark is not possible in other browsers.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up found one

    This code works great because it only shows up in IE (this one is on Sitepoint's Article pages:

    Code:
    <script type="text/javascript">
    	<!--
    	var txt = 'Bookmark This Article';
    	var url = 'http://www.sitepoint.com/article/ecommerce-site-2-months-99';
    	var who = 'I Built an eCommerce Site in 2 Months for $99!';
    	var ver = navigator.appName
    	var num = parseInt(navigator.appVersion)
    	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
    	   document.write('<a  class="bookmarkicon" href="javascript:window.external.AddFavorite(url,who);" ');
    	   document.write('onMouseOver=" window.status=')
    	   document.write("txt; return true ")
    	   document.write('"onMouseOut=" window.status=')
    	   document.write("' '; return true ")
    	   document.write('">'+ txt + '</a>')
    	}
    	-->
    	</script>
    Thanks for your help!

  6. #6
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by singersower View Post
    This code works great because it only shows up in IE (this one is on Sitepoint's Article pages:

    Code:
    <script type="text/javascript">
    	<!--
    	var txt = 'Bookmark This Article';
    	var url = 'http://www.sitepoint.com/article/ecommerce-site-2-months-99';
    	var who = 'I Built an eCommerce Site in 2 Months for $99!';
    	var ver = navigator.appName
    	var num = parseInt(navigator.appVersion)
    	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
    	   document.write('<a  class="bookmarkicon" href="javascript:window.external.AddFavorite(url,who);" ');
    	   document.write('onMouseOver=" window.status=')
    	   document.write("txt; return true ")
    	   document.write('"onMouseOut=" window.status=')
    	   document.write("' '; return true ")
    	   document.write('">'+ txt + '</a>')
    	}
    	-->
    	</script>
    Thanks for your help!
    Hi SingerSower, did you manage to get that working in Firefox as well ?

    Dez.

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    That code will show in most browsers simply because it is testing what the browser identifies itself as and most claim to be IE in order to get around browser detection scripts.

    Replace:

    Code:
    var ver = navigator.appName
    	var num = parseInt(navigator.appVersion)
    	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
    with:

    Code:
    if (window.external && window.external.AddFavorite) {
    in order to properly test for the brosers that support it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works in IE, FF and NS

    HTML Code:
    <script type="text/javascript"> 
    
    function bookmarksite(title, url){
        if (document.all)
            window.external.AddFavorite(url, title);
        else if (window.sidebar)
            window.sidebar.addPanel(title, url, "");
    }
    </script>
    
    <a href="javascript:bookmarksite('example.com', 'http://www.example
    .com')">Bookmark example
    .com!</a> 


  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE isn't the only browser to support document.all. Testing for it when you aren't going to use it is a very bad practice.

    There's a second problem with that:
    Many similar scripts use window.sidebar.addPanel() or rel="sidebar" to add a bookmark in Firefox. There's just one problem with those two methods -- they add a bookmark that is set to open in the sidebar (panel) by default instead of opening in the window/tab like a normal bookmark. rel="sidebar" works fine in Opera 7+, because in the dialog window there is an option to make the bookmark open in the sidebar or not. Firefox doesn't provide that option in the dialog window; to change it you have to open the properties of the bookmark.
    http://www.dynamicsitesolutions.com/...okmark-script/
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So is there any script that will work in IE and Firefox?

  11. #11
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Here's One that works in Internet Explorer, Firefox, Netscape, Mozilla, and Opera 9.

    Code:
    <p>Press CTRL-D to bookmark this page.</p>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  13. #13
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Here's One that works in Internet Explorer, Firefox, Netscape, Mozilla, and Opera 9.

    Code:
    <p>Press CTRL-D to bookmark this page.</p>
    Haha, the sarcasm is painfully appropriate with this thread; however, the above does not work on a Mac. Let's change it to this:

    Code:
    <p>Press CTRL-D or COMMAND-D to bookmark this page.</p>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •