Copy link to clipboard
Copied
Hi,
This may be a stupid question, but is there any way to open a web browser with a URL from an AE script, other than explicity lanuching the browser app via a sys.callSystem() command?
I'm asking because obviously scripts need to run on both Windows and MacOS, and the user's default/preferred browser isn't necessarily going to be IE or Safari. That and I'd need to find the file path of the browser anyway somehow.
It's to display external help.
Thanks,
Christian
OK so I've figured out a method that works.
Within your script dynamically create a local, temporary HTML file that does a simple URL redirect, such as:
<html>
<head>
<script language="javascript">
<!--
location.replace("http://www.quarterlightpictures.com");
//-->
</script>
</head>
<body>
</body>
</html>
called something like "openwebpage.html"
Then use new File("openwebpage.html").execute(); to open the HTML file in the default browser. The
...Copy link to clipboard
Copied
OK so I've figured out a method that works.
Within your script dynamically create a local, temporary HTML file that does a simple URL redirect, such as:
<html>
<head>
<script language="javascript">
<!--
location.replace("http://www.quarterlightpictures.com");
//-->
</script>
</head>
<body>
</body>
</html>
called something like "openwebpage.html"
Then use new File("openwebpage.html").execute(); to open the HTML file in the default browser. The Javascript in the HTML head tag forwards to the desired web page.
Copy link to clipboard
Copied
system.callSystem() can launch a URL without specifying the specific app. This code user's default browser. The last line is the main deal, the other stuff keeps it universal for PC and MAC.
//CHECKS FOR USER OS
function osCheck(){
var op = $.os;
var match = op.indexOf("Windows");
if(match != (-1)){
var userOS = "PC";// User is on PC
}else{
var userOS = "MAC";// User is on MAC
}
return userOS;
}
// RUNS OS CHECK FUNCTION
var userOSVer = osCheck();
//DEFINES PC OR MAC TERMINAL SYNTAX
if(userOSVer == "MAC"){
var urlLaunchCode = "Open";//Mac based
}else{
var urlLaunchCode = "Start";//PC based
}
//ONCLICK FUNCTION FOR YOUR URL BUTTON CONTROL
//urlLaunchCode = Open or Start / " " = keeps a space character separator / "http://myurl.com" = Defines the actual URL path
myURLButton.onClick = function(){system.callSystem(urlLaunchCode + " " + "http://forums.adobe.com/thread/993523?tstart=0")};
Copy link to clipboard
Copied
David, you've been very helpful on here, thank you! A much more elegant solution than mine too!
Christian
Copy link to clipboard
Copied
Here is an example of what I use to display a web page (to run directly from After Effects) :
var win = new Window ("dialog");
var winBrowserCmd = "C:/Program Files/Internet Explorer/iexplore.exe";
var macBrowserCmdStart = "osascript -e 'open location \"";
var macBrowserCmdEnd = "\"'";
var BtnURL = win.add("button", undefined, "Check for update");
BtnURL.onClick = LinkToURL;
win.add ("button", undefined, "Close", {name: "ok"});
function LinkToURL()
{
var URL = "http://www.google.fr/"; // your web page
if ($.os.indexOf("Windows") != -1)
system.callSystem(winBrowserCmd + " " + URL);
else
system.callSystem(macBrowserCmdStart + URL + macBrowserCmdEnd);
}
win.show ();
Copy link to clipboard
Copied
I had been using the below, not fully tested on mac however....
function checkOSandLaunch(theAddress){ // pass in www. no need for http etc.
$.writeln(system.osName);
if ( $.os.indexOf("Windows") != -1 ) {//SYSTEM IS ONE OF THE WINDOWS, XP OR 7 ETC - have the word Windows in it.
system.callSystem("cmd.exe /c\"start http://"+theAddress+"\"" );
}
else{//MUST BE MAC
system.callSystem("open http://"+theAddress+ "\"");
}
}//Close function.
Copy link to clipboard
Copied
I posted incorrect information in the last post, just to correct, this is what is working.
//=======================================================
function checkOSandLaunch(theAddress) { // pass in www.
var site=theAddress;
if ( $.os.indexOf("Windows") != -1 ) {//SYSTEM IS ONE OF THE WINDOWS
system.callSystem("cmd.exe /c\"start http://"+site+"\"" );
}
else{//MUST BE MAC
system.callSystem("open http://"+site);
}
}//Close function.
//=======================================================
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more