问题
I have an HTML file with embedded Javascript, and I want to convert it to a stand-alone exe.
Is that possible? How can I do it? Any html2exe tool out there?
P.S. If you must ask why, it's a very simple text-processing utility, but certain people want it (for reasons beyond me) as a desktop application.
回答1:
Try this open-source app Node-webkit (from here https://github.com/rogerwang/node-webkit) powered by Chromium JS engine and Node.js. You can pack the Node-webkit app package to a standalone .exe file. Please go through the documentation provided in the page. https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps
Read the Node.js documentation http://nodejs.org/api/ and see how powerful the API is! Node-webkit provides additional API to make app menubar, use system tray icon and post notifications etc and to make the application more native! Fortunately, Node-webkit is cross-platform so you can easily port apps to Linux and Mac OS X!
I strongly recommend you to use Node-webkit to make powerful desktop apps in HTML5 CSS3 and JavaScript. All the best! :)
Here are some examples : StormCloud, NitroTasks etc.. https://github.com/rogerwang/node-webkit/wiki/List-of-apps-and-companies-using-node-webkit
回答2:
They don't generate an exe but you may be interested in looking into Adobe AIR and its opensource rival Titanium
回答3:
If your desktops are limited to Windows have you considered creating it as a HTML Application?
You get the ability to launch from the desktop with out the need to create an EXE.
回答4:
If you just want to Run a single HTML web Page as an application / Exe , Please try the following methods.
1) Rename the .html page to .hta
2) Add the following code sniplet to your html pages tag.
<HEAD>
<HTA:Application
Border = Thick
BorderStyle = Complex
ShowInTaskBar = No
MaximizeButton = No
MinimizeButton = No
>
</HEAD>
回答5:
Depends on how complex the page is.
If it's a one pager, would a .hta work for you?
If it's multiple pages, you could use the IE Webbrowser control (or geckofx ) and a HTTPListener
Or you could host the asp.net runtime yourself.
In the past I've had success with the Webbrowser and injecting the HTML "by hand" (including all required scripts), but I wouldn't recommend it. It was a teeth grinding debugging nightmare. I kept going because it was "fun" :-)
回答6:
Here is an article explaining how to use a compiler from Micorosft. It's not exactly what you want, but it's a start, so I figured I would post it:
http://www.phpied.com/make-your-javascript-a-windows-exe/
It won't parse the HTML to make a GUI, but at least you can modify the JS code a little to compile, and then build a new UI on top of it.
回答7:
Surely your desktop application is your browser ? Can you create a standalone .html file that contains the Javascript within it (rather than referenced via a separate URL/.js file). Plus the .css etc.
Then you can distribute that HTML file. Double-clicking it will launch it in the browser, and with no requirements on a remote server.
回答8:
Under windows 7 it is very easy. Just follow these steps:
How to: Compile JScript Code from the Command Line
In My computer these files are in here: C:\Windows\Microsoft.NET\Framework\v4.0.30319
I think 4.0 version is newer :) After that:
To produce an executable with a different name using jsc
At the command prompt, type jsc /out:newname.exe file.js
I tried and it worked with some error messages.
来源:https://stackoverflow.com/questions/1057819/converting-htmljs-to-exe