10 Replies Latest reply on Aug 5, 2009 3:21 AM by Nand6

    Javascript code needed for "Add to Favorites" icon in Webhelp using RH8

    Nand6

      Hi,

        I have a huge problem in making the add to favorites icon click event associate with the appropriate code.

       

      This was the code i used in the Inline Javascript tab:

      <script type="text/javascript" language="JavaScript" src="showhide.js"></script>

      <input type="image" value="Add to Favorites" onclick="window.external.AddFavorite(location.href, document.title);return false"
      /="" name="AddTopicToFavorites_selected.gif"  src="AddTopicToFavorites_selected.gif"  

       

      <script type="text/javascript">var BookmarkURL="http://www.geekpedia.com"
      var BookmarkTitle="Geekpedia"
      // If the browser is Internet Explorer
      if (document.all)
      {
        // Add to Favorites (Internet Explorer)
          window.external.AddFavorite(BookmarkURL,BookmarkTitle)
            }
            else
            {
                    // Add to Bookmarks (Mozilla Firefox)
                    window.sidebar.addPanel(BookmarkTitle, BookmarkURL, '');
            }</script>
      Also in the onclick in the Edit tab, i wrote: window.external.AddFavorite(BookmarkURL,BookmarkTitle)

       

      It loads the add to favorites window very well as in any IE..But since the static word Geekpedia is being used, it displays the same and also navigates to the static URL http://www.geekpedia.com".

       

      I want to make it work dynamically...Please help me with any code change if any one has tried this before.

       

      One other thing that got messed up with was this icon replaced all other icons in the output....but...if i viewed the whskin_tbars.htm, i could see that the default icons appeared below somwhere...and there was this Add to Favorites icon appearing at the top...I dont know why these icons have got misplaced,,,i want to align them all in the same line..

       

      Please help me with this.....

      -Nanditha

        • 1. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
          Willam van Weelden Adobe Community Professional & MVP

          Hi,

           

          A long story, but I will need some more time to sort this out:

           

          Simple solutions:

               - Change the var BookmarkURL="http://www.geekpedia.com" to your own URL, such as: var BookmarkURL="http://myhelp.com"

               - Change the var BookmarkTitle="Geekpedia" to your name, such as: var BookmarkTitle="My help system"

               - Do not insert an image trough the javascript tab, add it using the image options with the custom toolbar items popup. This will probably solve your image problem.

           

          If you want to the URL dynamic, you need document.location.href, such as: var BookmarkURL = document.location.href; This however will get the adress of the current frame, which is whskin_tbars.htm.

           

          If you want to get the Title dynamic, you will need document.getElementsByTagName('title')[0]; and then you need to retrieve the title, as: xxx.firstChild.data,: such as:

               - var BookmarkGet = document.getElementsByTagName('title')[0];

               - var BookmarkTitle = BookmarkGet.firstChild.data;

           

          This always gets the URL and the Title of the frame you inserted the script in, which for the button toolbar is whskin_tbar.htm. When you insert this in any give topic, your bookmark will work fine, but will only call the topic, and not your skin.

           

          If you only want the URL of your helpsystem, I suggest you just change the  variables BookmarkURL and BookmarkTitle.

           

          If you want to target the current topic from any other location, such as the title bar, you need to address the top frame and then the topic. I don't know which frame this is, but I will look into it. This may take me some time though, but perhaps someone else knows which frames to address.

           

          Example for getting the url of your helpsystem dynamically:

           

          var BookmarkURL= this.parent.document.location.href;

          //Your projects main file does not have a title, so don't get it dynamically.

          var BookmarkTitle="My help system"

          // If the browser is Internet Explorer

          if (document.all)

          {

            // Add to Favorites (Internet Explorer)

              window.external.AddFavorite(BookmarkURL,BookmarkTitle)

                }

                else

                {

                        // Add to Bookmarks (Mozilla Firefox)

                        window.sidebar.addPanel(BookmarkTitle, BookmarkURL, '');

                }

           

          Long story, if you have any further questions, just ask.

           

          Greets,

           

          Willam

          • 2. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
            Nand6 Level 1

            Hi,

               this is the code i have modified to as per your mail:

             

            <script type="text/javascript">
            var BookmarkURL=this.parent.document.location.href
            var Bookmark Get=document.getElementsByTagName('title')[0];
            var BookmarkTitle=BookmarkGet.firstChild.data;
            // If the browser is Internet Explorer
            if (document.all)
            {
              // Add to Favorites (Internet Explorer)
                window.external.AddFavorite(BookmarkURL,BookmarkTitle)
                  }
                  else
                  {
                          // Add to Bookmarks (Mozilla Firefox)
                          window.sidebar.addPanel(BookmarkTitle, BookmarkURL, '');
                  }</script>

             

            What happened was the the icons have got misplaced on the toolbar..I have inserted the image to show you the same.

            • 3. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
              Willam van Weelden Adobe Community Professional & MVP

              Hi,

               

              Please insert the image using the screenshot tool. Your picture is queued, so I can't see it yet.

               

              Also, remove the space between Bookmark and Get, otherwise your script won't work.

               

              Greet,

               

              Willam

               

              Message was edited by: W. van Weelden

              • 4. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                Nand6 Level 1

                Hi,

                  I generated the output inserting the image from Image Options and also removed the space..

                 

                Yet, it still hasnt solved the problem.. You see the icons have been misplaced..and favorites icon is still not functional.

                forum_img.JPG

                • 5. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                  Nand6 Level 1

                  It giving me script error window since i have added the code.

                   

                  Is there any thing we need to add in the OnClick button of the Action tab?

                  • 6. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                    Willam van Weelden Adobe Community Professional & MVP

                    Hi,

                     

                    I sorted it out, but it seems that you cannot get the URL dynamically using javascript, although you can get the title of a page dynamically... You can get the url of a webpage with document.location.href, but you cannot use this string to add a bookmark. If anyone has a solution, i'd like to hear it.

                     

                    About your problem with the skin:

                         - First delete your custom button from the skin and generate a different output. If the skin is still malformed, your problem does not come from the bookmark button.

                         - When your skin is correct, go to Project Set-up and create a new button, style it any way you want, but don't add any inline JavaScript.

                         - Create a new file (with Notepad) and paste the following text, and change the variable url.

                     

                    function bookmarksite(){

                    //URL of your site, change to the url of your help

                    var url = "http://www.firstpage.com";

                    //get the title of the top frame

                    var title = parent.document.title;
                    if (window.sidebar) // firefox
                        window.sidebar.addPanel(title, url, "");
                    else if(document.all)// ie
                        window.external.AddFavorite(url, title);
                    }

                     

                         - Save this file as bookmark.js and add this file as a baggage file to the root of your project.

                         - Open you skin again and select your custom button. Go to the action tab and select JavaScript.

                         - In the files onClick, add: bookmarksite()

                         - Choose for external Javascript file and set bookmark.js.

                     

                    You will now have a functioning bookmark button, although not dynamically. Leave out any <script> and </script> tags and do not insert any pictures in the JavaScript file. Style your buttons only through the Project Set-up, or in whskin_tbars.htm when you like modifying the ouput.

                     

                    Greet,

                     

                    Willam

                    • 7. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                      Captiv8r Adobe Community Professional & MVP

                      Hi William

                       

                      I recall long ago attempting to create an Add to Favorites and I flat gave up on it after a period of time.

                       

                      Kudos to you for sorting what you did!

                       

                      Cheers... Rick

                       

                       

                      Helpful and Handy Links

                      RoboHelp Wish Form/Bug Reporting Form

                      Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!

                      Adobe Certified RoboHelp HTML Training

                      SorcerStone Blog

                      RoboHelp eBooks

                      • 8. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                        Willam van Weelden Adobe Community Professional & MVP

                        Hi Rick,

                         

                        Perhaps you should use that wish form for a change

                         

                        Greet,

                         

                        Willam

                        • 9. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                          Captiv8r Adobe Community Professional & MVP

                          Hi there

                           

                          LOL - Trust me... I do!

                           

                          Here's the deal. Some folks look at Peter and John Daigle and me and see our Adobe Community Expert logo and they figure that a wish form submitted by one of us would carry ten times the weight of one submitted by them. In reality, almost the opposite is true! Sure, we have a bit of an inroad with Adobe, but if Peter or I submitted a wish form for one feature, and 50 other users submitted a wish form for something different, theirs would be prioritized much higher than ours.

                           

                          That's precisely why we suggest using it. And often! Adobe does pay attention to these things and they don't just fall into some crack in the foundation.

                           

                          Cheers... Rick

                           

                           

                          Helpful and Handy Links

                          RoboHelp Wish Form/Bug Reporting Form

                          Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!

                          Adobe Certified RoboHelp HTML Training

                          SorcerStone Blog

                          RoboHelp eBooks

                          • 10. Re: Javascript code needed for "Add to Favorites" icon in Webhelp using RH8
                            Nand6 Level 1

                            Hi,

                               Thanks a ton for all the help..

                             

                            The Bookmark icon is functional now..I am yet to only add the correct URL now.

                             

                            This web help of mine will be put on a server and accessible through a GUI only. So probably i need to put the server's address here,

                             

                            Till then, the URL is not known to me as i open the homepage from the local drive in my system where the output gets generated,

                             

                             

                            Regards,

                            Nanditha