0

I want to make a simple local hosted html/js application (i.e. a set of html files), which allow:

  1. navigation through pages
  2. loading part of one page to another

Is it possible to make such an app without deploying local webserver?

UPD: I mean, how can I open C:\a.html and load from that file C:\b.html if all files are locally on my pc without running webserver?

Community
  • 1
  • 1
Ishayahu
  • 349
  • 1
  • 19
  • 5
    Yes just create the `.html` files and right-click-->Open in Chrome. – nicholaswmin Feb 04 '19 at 19:00
  • 2
    Just make a `.html` file and open it in your web browser... – Matthew Herbst Feb 04 '19 at 19:01
  • It is, however, there's 101 different ways you could do this, i.e. URL based navigation vs in-memory navigation, please provide more detail? Or as others have said, just have a few html files, possibly the most simplistic option of them all. – JO3-W3B-D3V Feb 04 '19 at 19:01
  • 1
    Why do you think there is an answer different than yes? – Sergio Rinaudo Feb 04 '19 at 19:02
  • The tricky part might be your second point: loading part of one page to another. But there is an answer to that here: https://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file – Olafant Feb 04 '19 at 19:21

2 Answers2

0

You can load one html file into another by using object or iframe containers. You will run into trouble with css that applies to a.html or b.html and so on.

<h1>This is a.html</h1>
<p>This is some content in a.html</p>

<object type="text/html" data="b.html"></object>

<p>This is some more content in a.html</p>

<p>And here is a <a href="b.html">link</a> to b.html.</p>

To load parts of one html file into another (as you asked) is not possible this way since you can't really access the content loaded into object or iframe containers with javascript.

There are some smart ideas about trying to do it in different ways that you might want to read. None of it is really handy.

Olafant
  • 829
  • 1
  • 7
  • 16
-1

Like others have said, it's as simple as creating the .html files, loading the .js files and calling others using regular links (as long as the other files are in the same folder), and opening the .html with you favorite browser.

But keep in mind that with Chrome and other browsers, you might run into issues if accessing resources other than css or js, due to security restrictions (CORS).

danboh
  • 758
  • 2
  • 11
  • 28
  • Doesn't chrome have like a web page editor tool for something like this? Like, can you start a new project in chrome? – Garrett Motzner Feb 04 '19 at 19:16
  • Chrome is a Web Browser, not a Web Editor. So no, you cannot start a new project in Chrome (although I'm sure there are plugins or extensions for this). For that I'd recommend looking at editors like Visual Studio Code, for example. Cheers – danboh Feb 04 '19 at 19:20
  • Ah, I was thinking the "open file" option in the developer tools. And while strictly speaking, chrome isn't a web editor, the developer tools severely blur that line. Cheers Back :). – Garrett Motzner Feb 04 '19 at 19:25
  • That's because the developer tools provide you more insights on how your front end code is executing, to help you debug issues. You do have the option to modify the code on the fly and see the results real time, but again, it's not an editor. – danboh Feb 04 '19 at 19:29
  • This answer doesn't address the second requirement mentioned in the question. Loading part of one html file into another is all but simple. – Olafant Feb 07 '19 at 16:08