Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I want to include html page in other page
foe ex. home.html and footer.html
i want to include footer.html in home.html page.
and when run home.html and (ctrl+U) view source code both page code will be
want to show.

please help me.

Thanks In advance.

Regards,
Ravi Walde
Posted
Comments
Kornfeld Eliyahu Peter 11-Aug-15 5:43am    
Plain HTML has no include feature...
What platform/server side do you use?

Please refer this link below for your answer as use can use

<div data-include="/path/to/include.html"></div>



http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file[^]
 
Share this answer
 
Comments
Member 10271164 11-Aug-15 7:07am    
sir, data-include is not work.
deepankarbhatnagar 11-Aug-15 7:13am    
try this where b.html is your another html file,

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

<body>
<div id="includedContent"></div>
</body>
</html>
Member 14933798 18-Nov-20 8:19am    
$(function(){
debugger;
$("#includedContent").load("https://test.bondevalue.com/offers.html");
});



Hi Sir,
I tried this many time it is not working. the below error is showing
Access to XMLHttpRequest at 'https://test.bondevalue.com/offers.html' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
hypermellow 11-Aug-15 7:18am    
As per the original comment to your question, there is no include functionality in plain/native HTML.

To get the above solution working, you'll need to use a suitable JavaScript library - which has been omitted from the above post.

https://github.com/LexmarkWeb/csi.js
Member 10271164 11-Aug-15 8:22am    
Sir,
I have tried this thing also apply references of this file in a.html. but did not show all a and b source code in browser
<script src="js/csi.js" type="text/javascript"></script>
<script src="js/csi.min.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>

please help me.
thanks in advance.
Hi,

To get Solution 1 working you need to include the file csi.js, which you can locate here[^].

As per the example shown on GitHub, to use this library you must include the file csi.js in your page header, then you need to add the data-include attribute with its value set to the file you want to include, on the container element.

HTML
<html>
  <head>
    <script src="csi.js"></script>
  </head>
  <body>
    <div data-include="Test.htm"></div>
  </body>
</html>


... hope it helps.
 
Share this answer
 
Comments
Member 10271164 12-Aug-15 1:23am    
sir, not work.
it shows only home page source code not both see the sorce code:
when ctrl+U then this code will show.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>

<script src="js/csi.js" type="text/javascript"></script>
<script src="js/csi.min.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#includedContent").load("Test.htm");
});
</script>
<script type="text/javascript"></script>

</head>
<body>
<!--<div id="includedContent" ></div>-->
<div data-include="Test.htm"></div>

</body>
</html>

I want both page code home page and test page source code in home page source code.
hypermellow 12-Aug-15 3:50am    
Hi,
As previously stated, HTML does not have an include feature.

The solution I posted is a working example of a type of JavaScript include feature (the html part of this was posted in Solution 1), it will not alter the browsers source code.

To include content that alters the browser source code, you need to use a server side technology that offers that feature (php/asp/asp.net etc).

Oh ... the source code you posted above is not the markup contained in the solution I posted. If you try the markup I posted, the browser will render the child HTML page into the parent ... but this will not change the browser source code.

... hope it helps.
Member 14933798 18-Nov-20 8:19am    
$(function(){
debugger;
$("#includedContent").load("https://test.bondevalue.com/offers.html");
});



Hi Sir,
I tried this many time it is not working. the below error is showing
Access to XMLHttpRequest at 'https://test.bondevalue.com/offers.html' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900