title: Using innerHTML to get a whole page content
body: <p>I am still a beginner in Javascript and I wondering if I can use innerHTML to post the whole HTML content from another page.
  I have used innerHTML to just post an HTML code within the same .js page. For example:</p>
  <p>I have <strong>main.js</strong> that contains this</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class MyComponent extends HTMLElement {
    connectedCallback() {
  this.innerHTML = `&lt;h1&gt;Hello world&lt;/h1&gt;`;
    }
  }
  
  customElements.define('my-component', MyComponent);</code></pre>
  </div>
  </div>
  </p>
  <p>and in the <strong>index.html</strong> I use this code to implement the main.js</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;script type="application/javascript" src="js/main.js"&gt;&lt;/script&gt; 
  &lt;/head&gt;
     
  &lt;body&gt;
      &lt;my-component&gt;&lt;/my-component&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>The question is can I include an HTML page instead <code>&lt;h1&gt;Hello world&lt;/h1&gt;</code> like <code>header.html</code> to get the whole HTML code from it? if not, Is there any way to do that?
  Thanks.</p>
  <p><strong>Edit:</strong> I mean for example if I have a page named footer.html and in that page, I have an h1 ex. &quot;Hello world&quot; And I need to use the same h1 in another page index.html without rewrite it again. Can I make that h1 as a template to use in any other page using javascript?
  My idea that I was looking for is:</p>
  <ul>
  <li>Making main.js</li>
  <li>get h1 from footer.html in main.js</li>
  <li>import that script in index.html</li>
  <li>using h1 in index.html
  I know that I can do that using &quot;include&quot; in PHP but I am just trying to do it by javascript.</li>
  </ul>