Skip to main content
Inspiring
February 23, 2019
Question

Open HTML file

  • February 23, 2019
  • 1 reply
  • 5197 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{}

}

Sudha_KAuthor
Inspiring
February 27, 2019

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.


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