Skip to main content
Inspiring
February 23, 2019
Question

Open HTML file

  • February 23, 2019
  • 1 reply
  • 5174 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
Braniac
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 28, 2019

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.");

};


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