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

gotoAnchorBehaviors not working on cross-document bookmarks

Community Beginner ,
Oct 20, 2021 Oct 20, 2021

Copy link to clipboard

Copied

Hi all, I was wondering if anyone had advice regarding scripting buttons & bookmarks in Indesign.

 

For some reason when I try to create a "Go to destination" action on a button from a script - it only seems to work when the bookmark is from the same document. If I pass in a bookmark from another document, it still creates the action, but it will revert back to the first bookmark (alphabetically) of the active document - NOT the one I told it to go to. This is easy to do from the UI, and this code used to work for me, as I've built a whole fit-for-purpose custom script for a client that is based around being able to create buttons linking to bookmarks in other documents. But now this script has stopped working and I can't seem to diagnose why 😩

 

 

var _sel = app.activeDocument.selection[0];
var bookmark = app.documents[2].bookmarks[0].destination;
//If bookmark is from another document, it will revert back to the first bookmark (alphabetically) of the active document
//If the bookmark is from the active document, it works as expected

_sel.gotoAnchorBehaviors.everyItem().remove();
var behavior = _sel.gotoAnchorBehaviors.add
(
    {
        behaviorEvent : BehaviorEvents.MOUSE_UP ,
        enableBehavior : true ,
        anchorItem : bookmark
    }
);

 

TOPICS
Scripting

Views

78

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 Expert ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

"This is easy to do from the UI, and this code used to work for me, as I've built a whole fit-for-purpose custom script for a client that is based around being able to create buttons linking to bookmarks in other documents."

 

Hi Atlas.Murray,

if that's easy to do from the UI, I would do it from the UI and read out the properties and values from that button.

Perhaps this is solved in a different way than you thought? Or there other factors that must be met. Like the save status of the documents or something like that. Just guessing here…

 

Regards,
Uwe Laubender

( ACP )

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 Expert ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

LATEST

this code used to work for me

Which InDesign version was that? And which one do you (or your customer) use now?

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