4 Replies Latest reply on Jul 6, 2016 4:16 PM by Oleh Melnyk

    Check hyperlink status

    selvam214 Level 1

      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

        • 1. Re: Check hyperlink status
          Loic.Aigon Adobe Community Professional

          Have you even tried looking at something ?

           

          InDesign ExtendScript API (10.0)

          • 2. Re: Check hyperlink status
            selvam214 Level 1

            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[n] = new Array();

                    for(var x in allHyperlinks[n].properties){ 

                    myArr[n].push(allHyperlinks[n].properties[x]+"\r");

                    }

                }; 

                alert(myArr);     

            };

             

             

            Thanks,

            selva

            • 3. Re: Check hyperlink status
              Loic.Aigon Adobe Community Professional

              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.

              • 4. Re: Check hyperlink status
                Oleh Melnyk Level 3

                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...