Skip to main content
Jeremy bowmangraphics
Inspiring
August 10, 2023
Answered

Javascript: get hyperlink text source(s) from text

  • August 10, 2023
  • 1 reply
  • 478 views

If the cursor happens to be located inside a hyperlink text source, the hyperlinks panel reveals which hyperlink is involved. If a run of text is selected, the hyperlinks panel reveals which hyperlink text sources the selected text overlaps (none, one, or many).

 

I can't figure out how to do this with JavaScript. Any suggestions?

 

Thanks in advance!

This topic has been closed for replies.
Correct answer m1b

Hi @Jeremy bowmangraphics, I believe you can use the findHyperlinks method of the text. For example:

var myHyperlinks = app.activeDocument.selection[0].findHyperlinks();
alert(myHyperlinks.length);

 - Mark

1 reply

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
August 10, 2023

Hi @Jeremy bowmangraphics, I believe you can use the findHyperlinks method of the text. For example:

var myHyperlinks = app.activeDocument.selection[0].findHyperlinks();
alert(myHyperlinks.length);

 - Mark

Jeremy bowmangraphics
Inspiring
August 11, 2023

That's exactly what I was looking for, and now my script is working perfectly, thanks very much!

m1b
Community Expert
Community Expert
August 11, 2023

Awesome! Good work. 🙂