Skip navigation
franklin
Currently Being Moderated

How to open a URL in the default browser via CC HTML Extension?

Oct 9, 2013 12:22 AM

Tags: #html #cc #csinterface

Hi,

 

I'm trying to open a link via the default browser in a HTML Extension for Photoshop CC built with Extension Builder 3.

 

With the initial example the "/indext.html" it look like this:

 

...
<li><button class="default" id="btn_PHXS" onClick="onClickButton('PHXS')" disabled="true">Run ps code</button></li>
...

 

and I changed the code from "/ext.js" to:

 

...

function onClickButton(ppid) {

    var csInterface = new CSInterface();

    csInterface.openURLInDefaultBrowser('http://www.adobe.com');

}

...

 

This is what the "/lib/CSInterface-4.0.0.js" looks like:

 

...
/**
 * Opens a page in the default system browser.
 *
 * @param url   The URL of the page to open. Must use HTTP or HTTPS protocol.
 *
 * @return One of these error codes:\n
 *      <ul>\n
 *          <li>NO_ERROR - 0</li>\n
 *          <li>ERR_UNKNOWN - 1</li>\n
 *          <li>ERR_INVALID_PARAMS - 2</li>\n
 *          <li>ERR_INVALID_URL - 201</li>\n
 *      </ul>\n
 */
CSInterface.prototype.openURLInDefaultBrowser = function(url)
{
    return cep.util.openURLInDefaultBrowser(url);
};
...

 

Since "util" doesn't seem to be defined  I get the message:

 

Uncaught TypeError: Cannot call method 'openURLInDefaultBrowser' of undefined

 

Is the something missing?

 

Thx,

 

frankin

 
Replies
  • Currently Being Moderated
    Oct 9, 2013 1:24 AM   in reply to franklin

    Hi Franklin,

     

    It seems that csInterface could be the issue as it is being returned as 'undefined'. I would check where you instantiate csInterface e.g.

     

    var csInterface = new CSInterface();

     

    and ensure that it is correctly working first e.g. it is not being returned as 'undefined'.

     

    Kind regards,

    Lea

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 11, 2013 1:13 AM   in reply to franklin

    Hi Franklin,

     

    Apologies for the delay but I have been trying to determine why this API is not been working. I have since discovered that, although this API is documented in the JS library, the behaviour has yet to be implemented into Photoshop CC. Offline I will try to determine why this API was included in the library when it was not ready but for the meantime, if you would like to open a browser, here is a workaround:

     

    Instead of using:

    //(new CSInterface).openURLInDefaultBrowser("http://www.adobe.com")

     

    // Use the createProcess API to open a browser. The following shows a workflow in Windows to open Internet Explorer.  

     

    var csInterface = new CSInterface();

    var rootDir = "/";

    var isWindows = window.navigator.platform.toLowerCase().indexOf("win") > -1;

     

    if (isWindows) {

                        rootDir = csInterface.getSystemPath(SystemPath.COMMON_FILES).substring(0, 3);

    }

     

    var processPath = "/usr/bin/open";

      if (isWindows) {

        processPath = rootDir + "Windows/explorer.exe";

    }

     

    var url = "http://www.adobe.com";

    window.cep.process.createProcess(processPath, url);

     

    Apologies for this inconvenience but we promise to keep you informed when openURLInDefaultBrowser API is fully supported.

     

    Kind regards,

    Lea

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points