0

I have been developing an app using HTML, CSS, and JS, using the App Mode command line argument for Google Chrome. It works nice, but I would like some ability to use the local file system without manual input from the user. That is, if I want a file accessed directly, I want it automatically done, not requiring the user to load the file in.

One option is to disable web security, which I'm not doing because there is a need to use Google Chrome normally. I haven't been able to use a command line argument to create a separate instance of Chrome, either.

I tried working on an HTA, but any attempt to port the code to HTA ends in headaches. Also, it doesn't seem to enjoy the perks that Blink/Webkit grants.

I looked into Electron and other similar platforms, and it requires installing a handful of things, which is a no-go due to the computer setup.

Are there any solutions with a sort of portable app, that can be dropped in a folder with the HTML document (say, labeled index.html or main.html), and upon opening the browser it directly opens that file without having to configure anything? A sort of barebones chromium-based browser that only opens a single file, allowing use of HTML, JS, CSS, along with local file access? Kind of like HTA but modern?

  • can you use `require`? – Nikos M. Oct 13 '21 at 17:00
  • @NikosM. assuming you're referring to RequireJS, I'm not quite sure how that would fix my issue. I don't need to load modules. I need a modern solution that provides the near-simplicity of HTA (where I can just rename an html file to HTA) with the modern touches of Electron without a need to install a program or full-fledged development environment. – Anthony LoPrimo Oct 13 '21 at 17:30
  • What you're asking for is highly desirable, but does not exist. When you tested HTA we're you aware that it runs in IE 5 mode by default or IE 7 mode if you declare doctype? You can run in IE 11 mode to get closer to modern browser capabilities. See the example I posted here: https://stackoverflow.com/questions/27704801/equivalent-to-accept-attribute-in-hta/68826015#68826015 – LesFerch Oct 13 '21 at 18:27
  • @LesFerch I've tried `` where IE = `9`, `11`, and `edge`. It all throws all sorts of errors that I need to figure out and it just seems to break further and further, the more I fix things. – Anthony LoPrimo Oct 13 '21 at 18:50
  • Does this answer your question? [hta - Equivalents in Firefox, Chrome - Is this old technology?](https://stackoverflow.com/questions/10619990/hta-equivalents-in-firefox-chrome-is-this-old-technology) – user692942 Oct 13 '21 at 19:05
  • If you're willing to share your code, I'd be interested to see if I can help make it work as an HTA. – LesFerch Oct 13 '21 at 19:22
  • @user692942 not quite. I peeked at the question before and it didn't seem to work. As I mentioned before (and others addressed), I basically want a modern alternative to HTA at this point. Something with the power of Chrome/Chromium, but with the ease of making an HTA. As I suggested, like a standalone and "portable" chrome app that only runs a specifically named HTML file in the directory, theoretically opening it to cross-compatible versions. – Anthony LoPrimo Oct 13 '21 at 19:49
  • @LesFerch I'll see. For the most part, there's nothing really identifying and I've gotten approval to host the tool on my website as I start to build a portfolio, so if I get that fully up and running, I can certainly work with you. I wish PMs were possible on this site. – Anthony LoPrimo Oct 13 '21 at 19:50
  • You can find me on GitHub. – LesFerch Oct 14 '21 at 01:26
  • @AnthonyLoPrimo, no I mean node's `require` as in node-webkit framework – Nikos M. Oct 14 '21 at 08:40
  • @NikosM. that means I have to install a runtime, and as I'm able to use javascript files already (also used a JS file to wrap a JSON object in it so it could be read by my app) I'm all set there. I need to be able to read/write local files without CORS errors being thrown (and without disabling web security). – Anthony LoPrimo Oct 15 '21 at 13:38

1 Answers1

4

The good news, is that it does exist, but it's not as "out-of-the-box" as HTA.

My team has migrated from HTA to WebView2.

The overall approach is to build a program with the WebView2 browser (you're basically building your own HTA like browser). Your javascript code can communicate back and forth with the program, which in turn has full access to local resources.

WebView2 is the Microsoft Edge Chromium browser, so you're getting the latest web tech and layouts (a big pain for HTA dev.). The program that contains the WebView2 control has full access to local files, scales, printers (without a pop-up dialog).

The approach has all the benefits of HTA (html / javascript programming, local file access, web based deployment, etc.), plus all layout and other benefits of a modern browser.

The program you'll build is very small, especially compared with the HUGE runtime of similar solutions, like Electron.

Rick Strahl has an excellent article on WebView2, and tips for building the program I'm describing. He has great advice on how to build an installer for it, including "Evergreen", which keeps the WebView2 up-to-date with the latest browser tech.

Microsoft's introduction to the technology here. https://learn.microsoft.com/en-us/microsoft-edge/webview2/

William Walseth
  • 2,803
  • 1
  • 23
  • 25
  • You're talking about a solution where the entry-level is a lot higher, you need to build a native app to use `WebView2` whereas HTAs used simple scripting and HTML. But that is indeed where we are now, there is nothing as simple as HTA on the market. In essence, you have to build your own HTA wrapper at this point. – user692942 Oct 14 '21 at 08:34
  • Yes, that's the situation as I know it. I haven't found anything like .HTA without bundling WebView2 into a native program. If you're really needing the technology, it's not a big project, using the links I've included. – William Walseth Oct 14 '21 at 10:14
  • Yeah, that essentially makes a quick solution for my project a complete bust. BUT, I could try to learn about it at home and create my own "HTA-like" solution, literally as I mentioned, dropping html files in the directory of the "browser", and let that browser become the launcher for the app. Just make it look for a file like index.html or main.html. Or something. – Anthony LoPrimo Oct 15 '21 at 13:35
  • Hey, so I decided to _create_ the solution to this question, though I'm a bit stumped as I've not really worked with forms and VS2019. Would you be able and willing to help me out? I'm mainly a web dev guy and I could definitely use the help. And if so, how would be best for me to be in touch? :O – Anthony LoPrimo Oct 25 '21 at 20:49
  • If your share your application in WebView2, the other guy needs to install and configure everything like you did? – Zano Dec 05 '21 at 20:19
  • Your users have to install the browser that you build with WebView2. If you do it right, it's a very simple install for your users. – William Walseth Dec 06 '21 at 13:52