1 Reply Latest reply on Nov 25, 2013 11:18 PM by elansezhianr72877736

    Auto hyperlinktargets

    Formzet - Zoetermeer Level 1

      I'm new to Indesign scripting.

      Can anyone help me how to create a script that creates Hyperlink targets of all pages in an active document.

      I don't know how to do this.

      I'm using Indesign CC on MacOS X

       

      Thank you

        • 1. Re: Auto hyperlinktargets
          elansezhianr72877736 Level 1

           

          Please try this:

           


          if (myXmlElm == "//uri"){
              var hypStr = myElement.xmlContent.contents.replace(/\n| /g, "").toString();
              var HypLink;
              if(hypStr.length != 0 && hypStr.match(/[a-z0-9]+/gi) != null){
                  if(hypStr.match(/[,\.]+$/) != null)
                      HypLink=hypStr.substring (0, hypStr.length-1);
                  else
                      HypLink=hypStr.substring (0, hypStr.length);
                    var hyperlinkURL = doc.hyperlinkURLDestinations.add({destinationURL:((HypLink.match(/^http/i) == null ) ? ("http://" + HypLink) : HypLink), hidden:true});
                    try{
                       hyperlinkSource = doc.hyperlinkTextSources.add(myElement.xmlContent);
                      }catch(e){};
                      fHyperlink = doc.hyperlinks.add(hyperlinkSource, hyperlinkURL);
                      fHyperlink.visible = false;