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

Check hyperlink status

Contributor ,
Jul 05, 2016 Jul 05, 2016

Hi All,

How to check the hyperlink status in CC2015 (red/green as per below highlighted).

Screen Shot 2016-07-05 at 1.04.31 pm.png

Selva

TOPICS
Scripting
564
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
People's Champ ,
Jul 05, 2016 Jul 05, 2016

Have you even tried looking at something ?

InDesign ExtendScript API (10.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
Contributor ,
Jul 05, 2016 Jul 05, 2016

Hi Loic,

I have tried to read the properties, but can't find the status method. Guide to me

hyerlinkstatus();

function hyerlinkstatus(){ 

    var d = app.documents[0]; 

    var allHyperlinks = d.hyperlinks; 

    var myArr = new Array();

    for(var n=0;n<allHyperlinks.length;n++){ 

        myArr = new Array();

        for(var x in allHyperlinks.properties){ 

        myArr.push(allHyperlinks.properties+"\r");

        }

    }; 

    alert(myArr);     

};

Thanks,

selva

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
People's Champ ,
Jul 05, 2016 Jul 05, 2016

Indeed, no properties or methods seem to actually return the hyperlink destination status as the panel does.

I hope I am wrong but if confirmed, then the solution might be to call command line and ping every single urls and analyze the result.

See doScript for that.

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 ,
Jul 06, 2016 Jul 06, 2016
LATEST

Well, in theory, you can send HEAD request through Socket connection, and check if response status code is 200 Ok

for example using this code

var site = "forums.adobe.com";

conn = new Socket;

if (conn.open (site+":80","UTF-8")) {

    var request = "HEAD / \n\n";

    conn.write (request);

    var reply = conn.read(50);

    conn.close();

    //alert(reply);

  

    var firstLine = reply.split("\n")[0];

    var statusCode = firstLine.split(" ")[1];

    var statusMsg = firstLine.split(/^.+\d{3}/)[1];

  

    if(statusCode != 200) alert(site + " is not reachable:\n" + statusMsg);

}


The problem is that socket didn't work with https (or at least I don't know how) and many sites now use it...

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