1

My question is simple. Like how you can use

<script type='text/javascript' language='javascript' src='.path/to/script.js'>
</script>

to link scripts in an HTML file, how do you do that to display multiple html files in one? For example, have multiple <div> tags, one link to each external HTML file in them for organizing purposes?
Thanks in advance.

Laurenz Albe
  • 129,316
  • 15
  • 96
  • 132
  • 1
    What you want is this https://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file or this https://stackoverflow.com/questions/17148357/including-external-html-file-to-another-html-file – manuel-84 Jun 30 '20 at 08:14

1 Answers1

0

I would suggest to arheive this consider using jQuery:

You can do this by using jQuery .load function. You can read more about using .load here

There is no proper direct way to import your .html or .php files by adding them in to the head

Note: There are few libraries you can search by googling BUT remember most of them are Deprecated and will not work in CHROME and OTHER BROWSER like this one here

You can define the location of where your other HTML files divs should be loaded like i have done below.

<html>

<head>
  <script type='text/javascript' language='javascript' src='.path/to/script.js'>
  </script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script>
    $(function() {
      $("#loadDivs").load("file.html");
    });
  </script>
</head>

<body>
  <div id="loadDivs"></div>
</body>

</html>
Always Helping
  • 13,486
  • 4
  • 8
  • 26
  • Thank you! I have never used jquery before so never would of thought of that. – uncannyorange Jul 02 '20 at 02:24
  • @uncannyorange Its ideal to use jQuery as it will make it easy for you learn as well. – Always Helping Jul 02 '20 at 02:25
  • Can it load my file if I made it so it can’t be embedded in – uncannyorange Jul 02 '20 at 02:27
  • @uncannyorange You can load dynamic content your `iframe` as well using the above example in my answer. Just change the div the iframe and load file content in there. It will hard to exactly know what are you trying to load BUT you can use the method in the answer to load anything from another `.html` or `.php` file – Always Helping Jul 02 '20 at 02:31