10 Replies Latest reply on Jan 31, 2016 1:49 PM by HeulwenM

    Loop thru Hyperlinks and add * at end of some hyperlink source text?

    HeulwenM

      Hi there,

       

      I'm sure this is very simple but my javascript is a bit rusty and a bit short of time so wondering if anyone might point me in the right direction?

       

      I need a script that loops thru all hyperlinks in a document (regardless of what styles are or aren't applied). It then needs to check the source text to see if it begins with 'www' or 'http'.

       

      If the source text does begin with 'www' or 'http' then do nothing. ELSE add an * at the end of the text. In other words if there was text in the document such as 'Click on this link' (and it had a hyperlink applied to it) it would be changed to 'Click on this link*'. If there was text in the document such as 'www.google.com' (and it had a hyperlink applied to it) it would remain unchanged. The hyperlinks themselves remain unchanged.

       

      So I am unsure of what my If/else statement should be???

       

      links = app.activeDocument.hyperlinks;

      for (i=0; i<links.length; i++)

      {if

      ???

      }

       

      Many thanks in advance for your help!!

       

      Heulwen