10 Replies Latest reply on Dec 16, 2011 2:57 AM by Willam van Weelden

    Script for Mailto link in footer with page URL

    Alberti Level 1

      [RH9]

       

      I'm trying to place the following script in the footer of a master page. It produces script errors. Can anyone fix it for me please?

       

      I'm inserting both text and graphical versions below incase the text doesn't post correctly --

      mailto script.png

      <p><script type="text/javascript">

      var mailSubject = 'User feedback';

      var mailBody    = 'Please leave this page reference in the message: ' + document.title + location.href;

      var mailDisplay = 'Click here to send feedback to support.';

      document.write(

          '<a href="mailto:xxxx@xxxx.com'

          + '?subject=' + escape(mailSubject)

          + '&body=' + escape(mailBody)

          + '">' + mailDisplay + '</a>'

          );</script></p>

        • 1. Re: Script for Mailto link in footer with page URL
          Alberti Level 1

          OK, I've found the error in line 3 (no semicolon after "document title") but I still can't get this script to accurately give the URL of the published page so that the recipient of the e-mail can click it and launch the page in the default window (2-pane).

           

          Any help would be appreciated -- I've seen a few scripts for this in websites and blogs but none of them are quite suitable for one reason or another.

          • 2. Re: Script for Mailto link in footer with page URL
            Praful_Jain Level 3

            hi,

            you can try the following code snippet, it is working fine on local folder, you should try it on web server as well.

             

            <script type="text/javascript">

            var mailSubject = 'User feedback';

            var currentDocumentAddress = location.href;

            if(typeof(gsStartPage)!='undefined' && typeof(gsRelCurPagePath)!='undefined')

            {

                //check they are not empty

                if(gsRelCurPagePath.length>0 && gsStartPage.length>0)

                {

                    currentDocumentAddress = gsStartPage+"#"+gsRelCurPagePath;

                }

            }

            var mailBody    = 'Please leave this page reference in the message: ' + document.title + ' '+ currentDocumentAddress;

            var mailDisplay = 'Click here to send feedback to support.';

            var szMailText = '<p><a href="mailto:xxx@yyy.com?subject='+escape(mailSubject)+ '&body=' + escape(mailBody)+ '">' + mailDisplay + '</a></p>';

            document.write(szMailText);

            </script>

             

             

            Please try this code snippet and see if you find any error or not.

             

            Thanks

            Praful Jain

            Adobe Robohelp Team

            1 person found this helpful
            • 3. Re: Script for Mailto link in footer with page URL
              Willam van Weelden Adobe Community Professional & MVP

              Hi,

               

              Just some extra info as Paful's solution seems right on the spot. To use an URL as text, you need to convertert the URL to text:

              var mailBody= 'Please leave this page reference in the message: ' + document.title + location.href.toString();

               

              Greet,

              1 person found this helpful
              • 4. Re: Script for Mailto link in footer with page URL
                Alberti Level 1

                If I preview it in the design editor", that code produces the following text in the e-mail body:

                 

                Please leave this page reference in the message: New Master Pagefile:///C:/ASK-TFS/Aurecon%20Support%20Knowledgebase/rltCEFC.htm

                 

                How would I make it come out as a clickable hyperlink to the page?

                • 5. Re: Script for Mailto link in footer with page URL
                  Alberti Level 1

                  http://forums.adobe.com/message/3976683#3976683

                   

                  At the above page I found a script that seems to work well enough although there some things about it I don't understand (hardly surprising, but I'm making progress). For example, it contains a variable called mailDisplay that doesn't appear to do anything.

                  • 6. Re: Script for Mailto link in footer with page URL
                    Praful_Jain Level 3

                    when you go for preview, a temporary file is created and hence this dummy name rltCEFC.htm. each time you preview any topic/snippet/master page, it tries to create a unique dummy file.

                    The script will work fine, on generating the output. Generate the webhelp output, as this is customized for webhelp output only. Try verifing this script on generated output and let me know if it works or not.

                    • 7. Re: Script for Mailto link in footer with page URL
                      Alberti Level 1

                      OK thank you, I will try it. It is a WebHelp Pro project (I shd have metioned that) but I will try it anyway. I’m keen to learn more about scripting. Do I need to place this in the Baggage folder?

                       

                      What source do you recommend for learning about using javascript and extendscript in RH?

                      • 8. Re: Script for Mailto link in footer with page URL
                        Praful_Jain Level 3

                        There are many good tutorials available on net for javascript.

                        Regarding Extendscript and its support in RoboHelp, you can go to the link @ http://www.adobe.com/devnet/robohelp/articles/robohelp-extendscript.html

                        This link specifical talks about how to get started with Extendscript with Robohelp and it has many resource links in the article.

                        thanks

                        Praful Jain

                        Adobe RoboHelp Team

                        • 9. Re: Script for Mailto link in footer with page URL
                          Captiv8r Adobe Community Professional & MVP

                          Hi there

                           

                          Just a heads up (in case you weren't aware) about the scripting. Although both use the word "script", they are in no way the same thing. So learning about one likely won't help with the other.

                           

                          JavaScript is used on web pages to accomplish different things as the pages are viewed and interacted with. For example, using JavaScript, you may create mailto links. Or perform calculations. Or store cookies that can later be retrieved.

                           

                          ExtendScript is a language that Adobe uses that allows you to manipulate your project in different ways. For example, skimming through all the topics in your system and counting words. Or replacing instances of a specific word with a variable.

                           

                          Personally, although I dabble in JavaScript and can usually make it bend to my whims, I may as well be trying to understand Sanskrit when it comes to ExtendScript. I guess I'm just dumb that way.

                           

                          Cheers... Rick

                           

                          Helpful and Handy Links

                          RoboHelp Wish Form/Bug Reporting Form

                          Begin learning RoboHelp HTML 7, 8 or 9 within the day!

                          Adobe Certified RoboHelp HTML Training

                          SorcerStone Blog

                          RoboHelp eBooks

                          • 10. Re: Script for Mailto link in footer with page URL
                            Willam van Weelden Adobe Community Professional & MVP

                            I might be the problem about the ExtendScript confusion. I dropped ExtendScript as an afterthought in a private conversation.

                             

                            As Rick points out, JavaScript is the scripting language for the web. ExtendScript is a programming language for Adobe applications. ExtendScript is based on JavaScript, but with extra's (and some things that are not supported). When you know JavaScript you'll be able to recognize ExtendScript and use your JavaScript knowledge to get started with ExtendScript. Learn JavaScript for the web, and when you're comfortable with that, you can try to make the jump to ExtendScript.

                             

                            Sorry about the confusion I caused.

                             

                            Greet,

                             

                            Willam