Tuesday, October 24, 2017

How to includeHTML page into another HTML page

I'm going to include content.html file inside main.html,

content.html file


<html> 
  <body>
    <div id="new-projects">
    <a href="howto_google_maps.asp">Google Maps</a><br>
    <a href="howto_css_animate_buttons.asp">Animated Buttons</a><br>
    <a href="howto_css_modals.asp">Modal Boxes</a><br>
    <a href="howto_js_animate.asp">Animations</a><br>
    <a href="howto_js_progressbar.asp">Progress Bars</a><br>
    <a href="howto_css_dropdown.asp">Hover Dropdowns</a><br>
    <a href="howto_js_dropdown.asp">Click Dropdowns</a><br>
    <a href="howto_css_table_responsive.asp">ResponsiveTab</a><br>
    </div>
</body>
</html>



main.html file


<html lang="en">
<head>
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
 <script>
$(document).ready(function() {
$('#result').load('content.html #new-projects', function() {
//alert("loaded");
});
});
 </script>
</head>

<body>
   <b>Projects:</b>
<div id="result"></div>
</body>

</html>





You need to include both file in same folder. Otherwise you have to change inside the load() method.


Run this as localhost/path/main.html

No comments:

Post a Comment