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

[JS][CS6] Change hyperlink page destination

Community Beginner ,
Feb 19, 2013 Feb 19, 2013

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

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

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 , Feb 19, 2013 Feb 19, 2013

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

...

Votes

Translate

Translate
Community Expert ,
Feb 19, 2013 Feb 19, 2013

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.

Votes

Translate

Translate

Report

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 Beginner ,
Feb 19, 2013 Feb 19, 2013

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.

Votes

Translate

Translate

Report

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 Beginner ,
Feb 19, 2013 Feb 19, 2013

Copy link to clipboard

Copied

LATEST

Never mind! This worked:

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

Votes

Translate

Translate

Report

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