Processing
 

Open a folder in finder/explorer from a webpage?

28/02/2012 16:02#1

Joined at: 11 months ago

Post: 9

Thank: 0

Thanked: 0

If I have a file system path can I open a window in Explorer (on windows) or in Finder (on OS X) displaying the folder that the path leads to?

Cookie points for answers that are cross-platform and/or plugin-less.

28/02/2012 16:13Top#2

DMoses

Member

Joined at: 10 months ago

Post: 5

Thank: 0

Thanked: 0

You need to be able to run a new process from a browser. There are a few ways to do this. I'll show the JNLP way to do this.

Create a jnlp file as follows:

    <?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0+" codebase="http://example/" href="jnlpTest.jnlp">     <information>         <title>Some Title</title>         <vendor>Some Vendor</vendor>         <homepage href="http://example/" />         <description>Some Description</description>     </information>     <security>         <all-permissions/>     </security>     <resources>         <j2se version="1.6+" />         <jar href="jnlpTest.jar" />     </resources>     <application-desc main-class="MainClass" /> </jnlp> 

Create a jnlpTest.jar from the following:

public class MainClass {     public static void main(String args[]) {         Runtime rt = Runtime.getRuntime();         try {             //TODO - different exec for Mac             rt.exec("explorer.exe");         } catch (IOException e) {             //exception         }      } } 

With a Manifest:

Manifest-Version: 1.0 Main-Class: MainClass 

Sign your JNLP jar:

keytool -genkey -keystore testKeys -alias jdc jarsigner -keystore testKeys jnlpTest.jar jdc 

place both the jar and jnlp file on a web server. Make sure the mime type JNLP is served as application/x-java-jnlp-file.

Reference for making a JNLP: http://java.dzone.com/articles/java-web-start-jnlp-hello

Now when a user clicks your jnlp link they will download the jar and be asked if it is ok to run. Running it will cause the explorer window to open. I know it's not the best solution, but any solution will require asking the users permission to execute code on their machine.

02/07/2016 11:17Top#3

Joined at: 11 months ago

Post: 5

Thank: 0

Thanked: 0

For node-webkit (NW.js) users you can use...

var gui = require("nw.gui");  document.querySelector("[data-location]").onclick = function() {   gui.Shell.showItemInFolder(__dirname + '/content/project/' + this.textContent); }; 
Similar articles

Open a folder in finder/explorer from a webpage?

5 years ago - Reply: 2 - Views: 80

How do I escape a reserved word in Actionscript?

5 years ago - Reply: 2 - Views: 199

Save PPS/PPT files as SWF using C#

5 years ago - Reply: 2 - Views: 171

Ways of making a graphic/visual novel in flash

6 years ago - Reply: 3 - Views: 114

Use PhoneGap + HTML5 and an Embedded Flash Movie

5 years ago - Reply: 2 - Views: 96

View word docs and PDF in browser?

5 years ago - Reply: 2 - Views: 52

ActionScript 3 Read JPEG quality

7 years ago - Reply: 2 - Views: 59

Export/Test Movie Issues

5 years ago - Reply: 3 - Views: 39

Flash always on top in Android browser workaround?

5 years ago - Reply: 2 - Views: 149

Sending Json Form from Flash AS3

5 years ago - Reply: 2 - Views: 29

parsing a swf/fla (using php?)

6 years ago - Reply: 2 - Views: 44

Getting high FPS on Flash/AIR games for mobile?

4 years ago - Reply: 2 - Views: 59

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re