Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Open HTML file in desktop app  RSS feed

 
Leticia Barbalho
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

I wanna open and display an HTML file in my app. I don't wanna open a browser, I wanna show it within my app.

I have searched and found this way:



Works fine for websites. But the thing is that I'm offline and I wanna open a local HTML file, not one in a site.
I've tried changing the path to: /home/me/path/myfile.html, but it gives me a MalformedURLException - no protocol.

How can I do to display local HTML files?

thanks
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The protocol you are missing is the "file" protocol. You need something like this:

file:///home/me/path/myfile.html

Here "file://" is the protocol and "/home/me/path/myfile.html" is the file name. Although it's possible that you may run into an implementation of the protocol that requires more or fewer slashes than what I put there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!