Pages

Thursday, August 25, 2016

Including a html file in another html

  • Using jQuery following code perfectly works

<html> 
  <head> 
    <script src="jquery.js"></script> 
    <script> 
    $(function(){
      $("#includedContent").load("b.html"); 
    });
    </script> 
  </head> 

  <body> 
     <div id="includedContent"></div>
  </body> 
</html>
 
 
  • By including an import 
<head>
  <link rel="import" href="/path/to/imports/stuff.html">
</head>
 
to access the content of the import use link element's .import property as below
 
 
var content = document.querySelector('link[rel="import"]').import; 
 
 
 
 



No comments:

Post a Comment