Copy link to clipboard
Copied
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"?
Thanks
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.itemByN
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Never mind! This worked:
app.activeDocument.hyperlinks.itemByName("Hyperlink 1").source.sourcePageItem.remove()