Help with javascript add bookmark firefox mozilla safari opera

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peckerwoodpimpn
    New Member
    • Feb 2007
    • 3

    Help with javascript add bookmark firefox mozilla safari opera

    I have a javascript that add's site to favortites. It works fine in IE7 but not in anything else. This is for a clients site who uses Mac and whats it to work in all browsers. If anyone could help me out I would really appreciate it. The website is http://arizona.uofinfo .com/uofinfo/index.php. If you need the code let me know and I will post it. Thanks a million.
  • peckerwoodpimpn
    New Member
    • Feb 2007
    • 3

    #2
    Here is the code.


    Code:
    <td width="60"><div align="right"><a href="javascript:window.external.AddFavorite(location.href, document.title);"><img src="http://bytes.com/images/BookMarkus.gif"></div>
    Last edited by acoder; May 23 '12, 04:10 PM.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Welcome to The Scripts.

      I'm afraid this is only possible in IE, and with the following code in Firefox/Netscape?
      Code:
      window.sidebar.addPanel(title, url, "")
      See this link for a neat version which checks if it's IE, otherwise it displays a message to press Ctrl-D (Ctrl-T on Opera). Combine that with the above by checking for window.sidebar then adding the code snippet.

      Hope that helps.

      Comment

      • senaka
        New Member
        • Feb 2007
        • 23

        #4
        Originally posted by acoder
        Welcome to The Scripts.

        I'm afraid this is only possible in IE, and with the following code in Firefox/Netscape?
        Code:
        window.sidebar.addPanel(title, url, "")
        See this link for a neat version which checks if it's IE, otherwise it displays a message to press Ctrl-D (Ctrl-T on Opera). Combine that with the above by checking for window.sidebar then adding the code snippet.

        Hope that helps.
        Please note that the above script works fine in FireFox. But in netscape, your bookmark will be appearing in the panel. Which might not be what you want. Try the ctrl-D alternative in netscape.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          That's why a put a question mark after Netscape (should've put it in brackets to make it stand out). Wasn't too sure about Netscape. Thanks for that info.

          Comment

          • peckerwoodpimpn
            New Member
            • Feb 2007
            • 3

            #6
            Thanks fellas I really appreciate the help. I am going to try that and I will get back to ya. Thanks again!

            Comment

            • stinkysGTI
              New Member
              • May 2007
              • 4

              #7
              I know this is a few months late, but I came across this post looking how to add a bookmark in Safari. Haven't found it yet, but here's a really useful script I found. It works for IE Win/Mac and Firefox Win/Mac - even Opera


              [CODE=javascript]function CreateBookmarkL ink() {

              title = document.title;
              url = window.location .href;

              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; }
              }[/CODE]
              Last edited by gits; Oct 23 '07, 06:16 PM. Reason: added code tags

              Comment

              • valenteen
                New Member
                • Jun 2007
                • 1

                #8
                [CODE=javascript]
                function addBookmark(tit le, url){
                if(window.sideb ar){ // Firefox
                window.sidebar. addPanel(title, url,'');
                }else if(window.opera ){ //Opera
                var a = document.create Element("A");
                a.rel = "sidebar";
                a.target = "_search";
                a.title = title;
                a.href = url;
                a.click();
                } else if(document.all ){ //IE
                window.external .AddFavorite(ur l, title);
                }
                }[/CODE]

                Comment

                • robbo23
                  New Member
                  • Jul 2007
                  • 1

                  #9
                  This code works really well in Firefox with one exception: once you have bookmarked the site, when you select the site from your bookmarks it opens up in the sidebar rather than the main window.

                  Has anyone found a solution to this?

                  Comment

                  • DUCMANs
                    New Member
                    • Oct 2007
                    • 1

                    #10
                    Originally posted by robbo23
                    This code works really well in Firefox with one exception: once you have bookmarked the site, when you select the site from your bookmarks it opens up in the sidebar rather than the main window.

                    Has anyone found a solution to this?
                    Hi, did you find a solution yet ?

                    There is a checkbox in the bookmark called "Load this bookmark in the sidebar". Uncheck it and your problem is solved. Question is how to do that using Javascript....

                    Regards, DUCMANs

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      DUCMANs, welcome to TSDN!
                      Originally posted by DUCMANs
                      There is a checkbox in the bookmark called "Load this bookmark in the sidebar". Uncheck it and your problem is solved. Question is how to do that using Javascript....
                      I'm not entirely sure, but I don't think that would be possible in JavaScript. Maybe you could just inform the user, but then that would probably defeat the purpose of an add bookmark link.

                      Comment

                      • tqd
                        New Member
                        • Mar 2008
                        • 1

                        #12
                        I have found this site that offers up a JS file that seems to cover all the browsers, and doesn't open the new bookmark in the sidebar: http://www.dynamicsitesolutions.com/...okmark-script/

                        You do have to pay for it for commercial sites.

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          All it does is alert that you have to press Ctrl-D, Ctrl-T, etc.

                          Comment

                          • secmazec
                            New Member
                            • Mar 2009
                            • 34

                            #14
                            It is a common bug by Mozilla Firefox, I recommend using something like this, before it is fixed:

                            Code:
                            <script type="text/javascript"><!--
                             // Copyright http://search-megaupload.com
                            function bookmarksite(title,url){
                            if (window.sidebar) // firefox
                            	//window.sidebar.addPanel(title, url, ""); Dont use until it's fixed
                            	alert('Dear Firefox user, please press CTRL+D to Bookmark this page!');
                            else if(window.opera && window.print){ // opera
                            	var elem = document.createElement('a');
                            	elem.setAttribute('href',url);
                            	elem.setAttribute('title',title);
                            	elem.setAttribute('rel','sidebar');
                            	elem.click();
                            } 
                            else if(document.all)// ie
                            	window.external.AddFavorite(url, title);
                            }
                            // --></script>
                            EXAMPLE:

                            http://search-megaupload.com/

                            Comment

                            • secmazec
                              New Member
                              • Mar 2009
                              • 34

                              #15
                              Hello, this is the code I use on my sites atm. It is ready to use the Firefox bookmark function when Mozilla fixes it. (just comment alert line and uncomment one above when they do so):

                              Code:
                              <script type="text/javascript"><!--
                              // All browser bookmark script
                              function bookmarksite(title,url){
                              if (window.sidebar) // firefox
                              	//window.sidebar.addPanel(title, url, ""); Dont use until it's fixed
                              	alert('Dear Firefox user, please press CTRL+D to Bookmark this page!');
                              else if(window.opera && window.print){ // opera
                              	var elem = document.createElement('a');
                              	elem.setAttribute('href',url);
                              	elem.setAttribute('title',title);
                              	elem.setAttribute('rel','sidebar');
                              	elem.click();
                              } 
                              else if(document.all)// ie
                              	window.external.AddFavorite(url, title);
                              }
                              // --></script>

                              Comment

                              Working...