![]() ![]() This is unlike web frameworks where the front-end code and the back-end code traditionally exist and execute in separate places. The example application above could load inside of a web browser without any modifications, but where NW.js differs from a web browser is that where an app.js file could only interact with the index.html’s contents in the context of a web browser, NW.js allows the app.js file to interact with the Operating System through a custom JavaScript API, as well as through Node.js. It looks for the package.json file, which points to the index.html file to load, and thus loads the web page into what looks like a web browser embedded inside of an application window. The NW.js application is able to load an application with a given path of the folder where the files live. It is required by NW.js for the application to load. ![]() This is the manifest file used by Node.js to load applications and libraries, and NW.js uses it to store configuration information about the desktop application. You’ll also notice a package.json file as well. There is also a CSS stylesheet for styling the contents of the index.html file, and an app.js file for executing JavaScript, in this case calling a simple dialog box with the text “from NW.js” inside of it. At this stage it’s identical to a website, and if you were to open it in a web browser it would work the same as it would in NW.js. The index.html web page is like most other web pages that you’ve seen - there is some HTML code for the page’s content, a link tag for the CSS stylesheet, and a script tag for the JavaScript. In the example illustrated above, the application’s files resemble those of a simple web site. Below is an example of how an example application works. These are things that can’t be done with a hosted web site, or even a locally hosted web site. ![]() This JavaScript API could control visual aspects like window dimensions, toolbar and menu items, as well as provide access to local files on the desktop. It was created by Roger Wang at Intel’s Open Source Technology Center in China, and worked by combining the Node.js programming framework with Chromium’s (then) browser engine - Webkit, hence the original name Node Webkit.īy combining Node.js with Chromium, Roger found a way to create applications that could not only load a local web site within an application window, but also could interact with the Operating System via a JavaScript API. NW.js is a framework for building desktop applications with HTML, CSS, and JavaScript. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |