3 Replies Latest reply on Feb 19, 2013 7:34 AM by PrntScr

    [JS][CS6] Change hyperlink page destination

    PrntScr Level 1

      Hi people!


      I bet this is simple, but I can't work it out.. and documentation is scarce.


      I want to change the PageDestination of a certain hyperlink via javascript.


      Lets go with this:

      app.activeDocument.hyperlinks.itemByName("Hyperlänk 8").destinationPage = 1 (or something else)


      ...the above doesn't work. What should I use instead of ".destinationPage"?



        • 1. Re: [JS][CS6] Change hyperlink page destination
          [Jongware] Most Valuable Participant

          PrntScr wrote:


          What should I use instead of ".destinationPage"?


          A page, not a number. A number could mean anything, whereas a page is .. a page


          But this


          app.activeDocument.hyperlinks.itemByName("Hyperlink 1").destinationPage = app.activeDocument.pages[0];


          does not work, because you forgot a level. A hyperlink has a destination, not a destination page, because hyperlinks can point to various items -- see http://jongware.mit.edu/idcs5/pc_Hyperlink.html.


          So, use this


          app.activeDocument.hyperlinks.itemByName("Hyperlink 1").destination.destinationPage = app.activeDocument.pages[0];


          and it will work, but only if the destination type already is a "HyperlinkPageDestination". If it's not, you have to add it first to your document's list of hyperlinkPageDestinations -- which is returned as a new object -- and then assign this object to the 'destination' property.

          • 2. Re: [JS][CS6] Change hyperlink page destination
            PrntScr Level 1

            Thanks Jongware! Once again to the rescue.


            Now I'm attempting to 'climb' up the object model, to reference the source of the hyperlink. It is a group (of a rectangle and a polygon) and has a name "BACK". I tried to extrapolate from the above, but my assumptions where incorrect:


            app.activeDocument.hyperlinks.itemByName("Hyperlink 1").source.hyperlinkPageItemSource.remove();


            ...doesnt remove the group. If you, or anyone else who has the time, could help me here I would greatly appreciate it.

            • 3. Re: [JS][CS6] Change hyperlink page destination
              PrntScr Level 1

              Never mind! This worked:


              app.activeDocument.hyperlinks.itemByName("Hyperlink 1").source.sourcePageItem.remove()

              1 person found this helpful