Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Javascript app into Windows app

Tags:

javascript

Is there any solutions except Adobe Air? I have heard that V8 kinda have something there.

Just don't have time for now, to write on another language whole app and then write 2x more code.

like image 759
Somebody Avatar asked Jun 24 '11 09:06

Somebody


People also ask

Can you make Windows apps with JavaScript?

If you're a Web developer—including ASP.NET—you can apply your existing knowledge of open standard HTML5, JavaScript and CSS3 directly to Windows Store app development.

Can Web App convert to desktop app?

Fluid App: A website can be converted to a desktop app only by uploading an app icon, name. and by entering the website URL. Fluid App is free, and you can create a desktop app that can run on the various OS.

Can I make a mobile app with JavaScript?

That's where JavaScript, specifically React Native, comes in. This JS-based tool lets developers build cross-platform mobile apps, instead of needing to code two completely separate apps. In fact, you'll probably recognize some of the apps that use it, like Discord, Microsoft Outlook, Facebook, and Instagram.


2 Answers

Maybe you could use jsc: Compiling JScript Code from the Command Line.

But you will have to replace browser-related objects by WinForms objects, which involves learning a new API, or use the .NET WebBrowser object (a browser widget showing only the content of a page, without bars except scrollbars) in a main window (Form object) and program it to load a URL to the page with your JS code.

Here is an excerpt from MSDN:

The WebBrowser control also lets you display content that you create in your application or you retrieve from a database or resource file. Use the DocumentText or DocumentStream property to get or set the contents of the current document as a string or data stream.

You can also manipulate the contents of a Web page through the Document property, which contains an HtmlDocument object that provides managed access to the HTML document object model (DOM) for the current page. This property is useful, when used in combination with the ObjectForScripting property, to implement two-way communication between your (Windows) application code and dynamic HTML (DHTML) code in a Web page, letting you combine Web-based controls and Windows Forms controls in a single user interface. You can use the Document property to call scripting code methods from your application(Windows code). Your scripting code can access your application through the window.external object, which is a built-in DOM object provided for host access, and which maps to the object that you specify for the ObjectForScripting property.

The WebBrowser control is a managed wrapper for the ActiveX WebBrowser control, and uses whichever version of the control is installed on the user's computer.

like image 186
Luc125 Avatar answered Oct 19 '22 05:10

Luc125


You can make a normal HTML file become a Windows App simply by changing the file's extension into ".hta"

Windows will treat your *.hta file like a winform application. This is called "html application" - HTA.

More documentations herer :

Html application

And of course, you can attach as much Javascript as you want in that HTA file, or even use external *.js file by doing like this :

<script src="your file.js"></script>
like image 43
vantrung -cuncon Avatar answered Oct 19 '22 06:10

vantrung -cuncon