Solved

Including header files in HTML pages

Posted on 2014-03-04
4
218 Views
Last Modified: 2014-03-05
Including header and footer files in ASP was very easy.

But how do I achieve it in a pure HTML page?
0
Comment
Question by:RTKHOT
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39905720
You can't.  'pure' HTML does not have a command to do that.  Something other than HTML is always required to do that.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 200 total points
ID: 39905732
Dave, can you turn on serverside includes?

Otherwise, you could do this in js or jquery. I prefer using jquery..
<script>
$(function() {
$.ajax({
  url: "myHeader.html",
  cache: false
})
  .done(function( html ) {
    $( "#header" ).append( html );
  });
 });
</script>
<div id="header"></div>

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39905751
Dave, can you turn on serverside includes?
Yes but that is still not 'pure' HTML.
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 39905793
HTML inside "includes" need some server side technology way to insert. You can also think of IFRAME way.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question