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

Open HTML file

Contributor ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

Hi,

I am opening html file in photoshop javascript for both PC and MAC OS. Its working for PC.  For MAC its was working with lower version CS3 but not working with the version CS6.

How to open html file in mac for Photoshop CS6?

var htmlFile = new File("fileToPath");

htmlFile.execute();

Thanks,

Sudha K

TOPICS
Actions and scripting

Views

4.0K

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
Adobe
Community Expert ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

"fileToPath"  looks like a string to me not a variable that may be a "path\FileName.html"

file.execute();

Your system should launch the application associated with the file extention

On a PC this works for me. If there is no association for .html  the use would be  put into a open with application dialog

try{

   var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");

   URL.open("w");

   URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');

   URL.close();

   URL.execute();   // The temp file is created but this fails to open the users default browser using Photoshop CC prior Photoshop versions work

}catch(e){alert("Error, Can Not Open.");};

JJMack

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
Contributor ,
Feb 24, 2019 Feb 24, 2019

Copy link to clipboard

Copied

Hi,

     fileTopath is html file.  File contains tables contents to display.  Its working in one system which contains lower version CS3 but not working with CS6.  Don't know why? Any reason is there ?

     I was using the below code for InDesign and it was working fine. But for photoshop its not working. Throwing the below error.

openHtml(htmlFilePath)

function openHtml(htmlFilePath)

{

     if(osName == "Macintosh")

     {

         //try{

             htmlFilePath = htmlFilePath.replace("%20"," ","gi");

             var str = "";

             str += "tell application \"Safari\"\r";

             str += "activate\r";

             str += "set htmlFile to \""+htmlFilePath+"\"\r";

             str += "open htmlFile\r";

             str += "end tell";    

             app.doScript(str, ScriptLanguage.applescriptLanguage);

         //}catch(e){}

     }else if (osName == "Windows")

     {

         var htmlFile = new File(htmlFilePath);

         htmlFile.execute();

     }else{}

}

Err.jpg

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
LEGEND ,
Feb 25, 2019 Feb 25, 2019

Copy link to clipboard

Copied

doScript belongs to inDesign I think, you can't use it in Photoshop.

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 Expert ,
Feb 25, 2019 Feb 25, 2019

Copy link to clipboard

Copied

Photoshop has a doAction which will play an action in an action set.   I would think  Java File object function execute should work on a Mac that Mac OSX would have a file type association to applications like windows.

JJMack

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
Contributor ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Can you please guide me how to open...

How to open html file in mac os default browser.

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 Expert ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

I do not use a Mac.  I'm sure there is some way you can configure mac  so some file type are associated with a default application for that file type.  When you execute that file type your MAC OS will launch the associated application and past the file being executed to that application.  Itn an OS function not a Photoshop function.  If you exec the file from finder a double click perhaps on a html file I would expect  OSX would launch safari and pass the html file to safari to open.

JJMack

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
Contributor ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Yes we do it from applescript.  I have posted the code also.

But i wanted to do it from photoshop code using javascript/applescript etc..

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 Expert ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

You have been told the code you post for  mac is bad,  Photoshop  scripting does not have a doScript feature where other Adobe application scripting may.   the following is not valid in Photoshop

app.doScript(str, ScriptLanguage.applescriptLanguage);

if

htmlFilePath

is a valid file path I would think the code would work on a Mac like it does on a PC fileobject.execute();

var htmlFile = new File(htmlFilePath);

htmlFile.execute();

JJMack

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
Contributor ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

Hi,

     html file path is valid and also exists there. When i trying this in MAC, browser is blank and showing the url addres is like below.

     browser.jpg

      Html file is not opening...

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 Expert ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

Tru running this on your Mac

// A Photoshop Script by JJMack's

// This script is supplied as is. It is provided as freeware.

// The author accepts no liability for any problems arising from its use.

#target photoshop

app.bringToFront();

/*

<javascriptresource>

<name>HelpPhotoCollageToolkit</name>

<about>$$$/JavaScripts/HelpPhotoCollageToolkit/About=Web Help for JJMack's Photo Collage Toolkit.^r^rCopyright 2010 Mouseprints.^r^rOpen Browser Toolkit Help Page</about>

<category>JJMack's Collage Script</category>

</javascriptresource>

*/

try{

   var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");

   URL.open("w");

   URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');

   URL.close();

   URL.execute();   // The temp file is created but this fails to open the users default browser using Photoshop CC prior Photoshop versions work

}catch(e){

alert("Error, Can Not Open.");

};

JJMack

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
Contributor ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

Can u pls explain the above code. Because my html file already have contents. So can i use the below one?

#target photoshop 

app.bringToFront(); 

var URL = new File(htmlFilePath);

URL.execute();

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 Expert ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

LATEST

The code creates a temp html .  The HTML code written to the file redirect a browser processing the html to redirect from the  html file to a toolkit help page on my web server

The javaScript used  FileObject.execute(); to have your OS pass the temp html file to the application associated with html files which would normally be some web browser.

Did the code work on you Mac?  Did a browser on your mac open my toolkit help on my web server processing the temp html file written by the JavaScript?

URL  is a new file object.  The new file was open, the html code written into it and was closed.  Once closed Fileobject.execute();   gave the file to you OS for execution.

The other code is boilerplate I just stick in the beginning of a script for I do not knows JavaScript and just hack a Photoshop scripting

JJMack

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