Skip to main content
Inspiring
February 23, 2019
Question

Open HTML file

  • February 23, 2019
  • 1 reply
  • 5175 views

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

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
February 23, 2019

"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
Sudha_KAuthor
Inspiring
February 25, 2019

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

}

JJMack
Community Expert
Community Expert
February 27, 2019

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


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