Reputation: 119
How would I link identical HTML used in several pages, instead of adding the same markup in all of the several pages.
Upvotes: 4
Views: 6364
Reputation: 2089
You might want to look into asp.net MVC framework. You have a Shared View in it to write the part which is common between different pages.
Upvotes: 0
Reputation: 59637
You can do this using an iframe
on each of the several pages, with the src
being the common HTML.
It also is possible on the client-side using javascript. jQuery makes this particularly easy providing a load
method. You can use jQuery.load()
to add an HTML block into elements across different HTML pages.
As an example, if every one of the pages has an div
named content
:
<div id=`contents`></div>
Then you could do this in each page:
$('#content').load('commonContent.html');
Upvotes: 3
Reputation: 2114
You should check: http://www.triadwebcrafters.com/article_server_side_language.cfm and Best practice for inserting large chunks of HTML into elements with Javascript?
Upvotes: 1
Reputation: 2009
If it's allowed by the web host, server side includes (SSI) will do the trick. So, to insert the contents of a file "common.htm", just put this in the html for each page:
<!–-#include virtual="common.htm” -–>
you can read about it here: http://en.wikipedia.org/wiki/Server_Side_Includes
Upvotes: 1
Reputation: 1028
It is possible using JavaScript http://webdesign.about.com/od/javascript/ht/htjsincludehtm.htm
Upvotes: 2
Reputation: 175088
It can be done from the server side.
If you're using PHP, you can use include()
.
Upvotes: 3