Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
8

Javascript: get hyperlink text source(s) from text

Engaged ,
Aug 10, 2023 Aug 10, 2023

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!

TOPICS
Scripting
235
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 10, 2023 Aug 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

Translate
Community Expert ,
Aug 10, 2023 Aug 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2023 Aug 11, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2023 Aug 11, 2023
LATEST

Awesome! Good work. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines