Copy link to clipboard
Copied
Hello, Everybody!
Is it possible, to make link to webpage in staticText control in UI in JSX-script?
Here is an example of the code. I need to modify it to make link active.
var dlgResource = "dialog {\
text : 'Link To Adobe in Static Text Control',\
\
stTextQuestion : StaticText{\
text : 'how can I turn the following text into an active link?',\
justify: 'left'\
}\
\
stTextLink : StaticText{\
text : 'www.adobe.com',\
justify: 'center'\
}\
\
}"
var dlgWithLink = new Window(dlgResource);
dlgWithLink.center();
dlgWithLink.show();
This is what you need,
make good use of it
//Made Ciccillotto
main()
function main() {
var docRef = app.activeDocument;
var myWindow = new Window ("dialog", "Link To Adobe in Static Text Control", undefined, {closeButton: true});
var myLText = myWindow.add ("statictext", undefined, "how can I turn the following text into an active link?");
var scriptFolder = new File(WhoAmI()).parent;
var myLink = myWindow.add ("statictext", undefined, "link open adobe");
myLink.graphics.foregroundColor
...
Copy link to clipboard
Copied
This is what you need,
make good use of it
//Made Ciccillotto
main()
function main() {
var docRef = app.activeDocument;
var myWindow = new Window ("dialog", "Link To Adobe in Static Text Control", undefined, {closeButton: true});
var myLText = myWindow.add ("statictext", undefined, "how can I turn the following text into an active link?");
var scriptFolder = new File(WhoAmI()).parent;
var myLink = myWindow.add ("statictext", undefined, "link open adobe");
myLink.graphics.foregroundColor = myLink.graphics.newPen (myWindow.graphics.PenType.SOLID_COLOR, [1.00, 0.255, 0.255, 1],lineWidth=1);
myLink.onClick = function () {
openInBrowser("http://www.adobe.com/");
}
myWindow.show ()
} // end of function main
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
function openInBrowser(/*str*/ url) {
var isMac = (File.fs == "Macintosh"),
fName = 'tmp' + (+new Date()) + (isMac ? '.webloc' : '.url'),
fCode = isMac ?
('<?xml version="1.0" encoding="UTF-8"?>\r'+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" '+
'"http://www.apple.com/DTDs/PropertyList-1.0.dtd">\r'+
'<plist version="1.0">\r'+
'<dict>\r'+
'\t<key>URL</key>\r'+
'\t<string>%url%</string>\r'+
'</dict>\r'+
'</plist>') :
'[InternetShortcut]\rURL=%url%\r';
var f = new File(Folder.temp.absoluteURI + '/' + fName);
if(! f.open('w') ) return false;
f.write(fCode.replace('%url%',url));
f.close();
f.execute();
$.sleep(500);
f.remove();
return true;
}
function WhoAmI() {
var where;
try {
var FORCEERROR = FORCERRROR;
}
catch( err ) {
where = File(err.fileName);
}
return where;
}
Copy link to clipboard
Copied
Great Thank's! It work!