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

Link to webpage in staticText control in UI in JSX-script

Community Beginner ,
Feb 20, 2024 Feb 20, 2024

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();

 

TOPICS
Actions and scripting
198
Translate
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

Enthusiast , Feb 21, 2024 Feb 21, 2024

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 
...
Translate
Adobe
Enthusiast ,
Feb 21, 2024 Feb 21, 2024

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;
}

 

 

 

 

 

Translate
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 21, 2024 Feb 21, 2024
LATEST

Great Thank's! It work!

Translate
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