4 Replies Latest reply on Oct 3, 2014 6:46 AM by matias.kiviniemi

    Hyperlink in the scripts's UI

    Gustavo Del Vechio Level 3

      Hi friends

       

      I was looking in the JavaScript Tools guide but did not find this information (or perhaps I missed it). Would it be possible to a statictext become a hyperlink? And a portion of a text in an alert pop-up? For example:

       

      var dlg = new Window ("dialog", "My dialog", undefined);

       

      var myText = dlg.add ("statictext", undefined, "www.mysite.com");

       

      var myButton = dlg.add ("button", undefined, "Click here");

       

      myButton.onClick = function (){

      alert("Please visit www.mysite.com for more informations, or send e-mail to me@mysite.com.");

      };

       

      dlg.show();

       

      Could the "www.mysite.com" in the statictext and alert be an hyperlink? The same for the e-mail "me@mysite.com"? Does JavaScript UI allows it?

       

      Thank you very much

      Gustavo.

        • 1. Re: Hyperlink in the scripts's UI
          DBarranca Level 4

          Gustavo,

          as far as I know that's not possible within an Alert. But if you resort to popping up a dialog, you can attach an eventListener like this one:

           

          dlg.myText.addEventListener('click', (function() {
            var fname, shortcut;
            fname = "_shortcut.url";
            shortcut = new File("" + Folder.temp + "/" + fname);
            shortcut.open("w");
            shortcut.writeln("[InternetShortcut]");
            shortcut.writeln("URL=http://www.mywebsite.com");
            shortcut.writeln();
            shortcut.close();
            shortcut.execute();
            $.sleep(4000);
            return shortcut.remove();
          }), false);
          

           

          Not very much elegant I know, but it works ;-)

          Cheers,

           

          Davide Barranca

          www.davidebarranca.com

          • 2. Re: Hyperlink in the scripts's UI
            JJMack Most Valuable Participant

            You can also write an html file and execute it. The users default browser should start.  In that html file you can redirect the browser to your web site where your help is maintained and perhaps in there is a mail to html tag and a download link to the latest version. Here is what my help dialog button does.

            function help() {

                      try{

                                var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");

                                URL.open("w");

                                URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');

                                URL.close();

                                URL.execute();

                      }catch(e){

                                alert("Error, Can Not Open.");

                      };

            }

             

            You could keep the html code local so no internet connection is required. Where the html includes your alert text and has a mail to tag. The Script keeps running is not stopped by the alert and a browser windows opens.

            1 person found this helpful
            • 3. Re: Hyperlink in the scripts's UI
              Gustavo Del Vechio Level 3

              Thank you very much Davide and JJMack

               

              I´ll try this way

               

              Best Regards

              Gustavo

              • 4. Re: Hyperlink in the scripts's UI
                matias.kiviniemi Level 3

                Thanks also, saved my day