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

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

Community Beginner ,
Feb 20, 2024 Feb 20, 2024

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

 

TOPICS
Actions and scripting

Views

96

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

correct answers 1 Correct answer

Engaged , 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 
...

Votes

Translate

Translate
Adobe
Engaged ,
Feb 21, 2024 Feb 21, 2024

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

 

 

 

 

 

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

Copy link to clipboard

Copied

LATEST

Great Thank's! It work!

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