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

How to validate whether Hyperlink already present or not in Indesign using Javascript?

Engaged ,
Dec 29, 2021 Dec 29, 2021

Is there any way to validate the Hyperlinks already added in the indesign document.

TOPICS
How to , Scripting
909
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 , Dec 30, 2021 Dec 30, 2021

Hi,

Below is the snippet that will help you to tell whether hyperlink exists or not.

var doc = app.activeDocument;
var _hyperLink = doc.hyperlinks.itemByName('test');
if(_hyperLink.isValid)
    alert("Exists");
else
    alert("Not exists");

 

Assuming, hyperlink with name "test" exists in teh indesig document.

Translate
Community Expert ,
Dec 30, 2021 Dec 30, 2021

Look into the Hyperlink panel.

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 ,
Dec 30, 2021 Dec 30, 2021

Hi,

Below is the snippet that will help you to tell whether hyperlink exists or not.

var doc = app.activeDocument;
var _hyperLink = doc.hyperlinks.itemByName('test');
if(_hyperLink.isValid)
    alert("Exists");
else
    alert("Not exists");

 

Assuming, hyperlink with name "test" exists in teh indesig document.

Best regards
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
Advocate ,
Feb 12, 2022 Feb 12, 2022
LATEST

This would do the trick.

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 ,
Dec 30, 2021 Dec 30, 2021

Can you be more specific? If you want to check if a block of Text has hyperlinks, you can use myText.findHyperlinks(), which will return an array of all hyperlinks in that text (array length can be 0)

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