Copy link to clipboard
Copied
I want create a Button from script.
I had add by script:
var doc=app.documents[0];
var txtMain=doc.textFrames[0];
var oCell_URL=txtMain.tables[0].cells[1];
var btnLink=oCell_URL.buttons.add();
Now, How can add action for this button?
Ex:
1 Correct answer
Hi @daitranthanhoa ,
look up the DOM documentation for the Button object.
You'll add a gotoURLBehavior to the button object.
Sample code:
var doc = app.documents.add();
var myButton = doc.buttons.add({ geometricBounds : [0,0,"50mm","50mm"]});
myButton.gotoURLBehaviors.add
(
{
behaviorEvent : BehaviorEvents.MOUSE_DOWN ,
enableBehavior : true ,
url : "http://adobe.com"
}
);
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Button.html
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#GotoURLBehavior.html
...Copy link to clipboard
Copied
Hi @daitranthanhoa ,
look up the DOM documentation for the Button object.
You'll add a gotoURLBehavior to the button object.
Sample code:
var doc = app.documents.add();
var myButton = doc.buttons.add({ geometricBounds : [0,0,"50mm","50mm"]});
myButton.gotoURLBehaviors.add
(
{
behaviorEvent : BehaviorEvents.MOUSE_DOWN ,
enableBehavior : true ,
url : "http://adobe.com"
}
);
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Button.html
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#GotoURLBehavior.html
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Try the ShowHideFieldsBehavior. Look it up in the DOM documentation:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ShowHideFieldsBehavior.html#d1e186415
Regards,
Uwe Laubender
( Adobe Community Professional )

