Copy link to clipboard
Copied
I have been requested to write a series of scripts that will automate the building of interactive objects such as buttons that will then activate a web page or an email address. I looked at the object model and the Button object has a property called gotoURLBehaviors which, if one looks at it on a button that is already created, contains the web address of whatever web page the button is pointed to. The button works.
However, if I attempt to write to this list using the add method ESTK tells me that this property is readonly.
Using Javascript, how can I get my URL associated with the button I am creating?
It's got the add-method
var niceButton = app.activeDocument.buttons.add(undefined, undefined, app.activeDocument.pages[0]);
with(niceButton){
geometricBounds = [0,0,10,10]
gotoURLBehaviors.add({url :'www.myurl.com'})
}
Copy link to clipboard
Copied
It's got the add-method
var niceButton = app.activeDocument.buttons.add(undefined, undefined, app.activeDocument.pages[0]);
with(niceButton){
geometricBounds = [0,0,10,10]
gotoURLBehaviors.add({url :'www.myurl.com'})
}
Copy link to clipboard
Copied
Well, I'm not exactly sure why this did not work:
var ThePage = TheDoc.pages.item(0);
var TheButton = ThePage.buttons.add({name:"HyperlinkButton1"});
var Behavior = TheButton.gotoURLBehaviors.add("www.amazon.com");
But it dod not and yours did, so I humbly thank you and offer you a free lunch the next time you are in majestic Brookfield-in-the-toolies.
Take care.
John
Copy link to clipboard
Copied
nice
look at your last line. the assigning of the property url is not in the rigth syntax.
Cheers
Hans-Gerd Claßen
Copy link to clipboard
Copied
Well, now, that's just the thing, Hans. In the scripting guide, using "bounds" as an example, I may instantiate an object like this:
var MyObject = new somethingOrTheOther(10,10,20,20);
or I may do it like this:
var MyObject = new somethingOrTheOther([10,10,20,20]);
or I may do it like this:
var MyObject = new somethingOrTheOther({bounds = (10,10,20,20)});
Though your help was immensely appreciated, I searched for two hours on my own looking for a syntax that would work. Did you discover it by trial and error, or is it stated someplace else where I can look and find other important, if hidden bits of information?
I am also curious to know why the documentation calls that property "readonly" when in reality it is quite manipulable if you use the right syntax?
TIA!
R,
John
Copy link to clipboard
Copied
@John – the thing is:
you can add* and remove** gotoURLbehaviors (and there could be several in one single button!), but if you want to manipulate one (readonly!) you will fail.
So you first have to remove the old one(s) and add a new one with the new specs.
Uwe
*where the add() method is listed under the Class description of "GotoURLbehaviours" (The collection discription)
**and the remove() method under the Class description of "GotoURLbehaviour" (the single Object)