RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: HTML
Expertise: Intermediate
Jan 23, 2007

Use Javascript Templates in Static HTML Pages

If your site contains pure static HTML pages, you'll have a tedious time entering the same header and footer HTML tags on all the pages. This is where JavaScript comes to the rescue.

JavaScript allows you to centralize this information in header.js and footer.js files. This way, you call those files in your HTML pages:


<!-- Page Header
<script src=header.js>

<!--- Content of the Page -->

<!-- Page Footer
<script src=header.js>


Include in the header.js file:

document.write('Header Html tages');
Include in the footer.js file:

document.write('Footer Html tages');
Another advantage of using JavaScript in this manner is that any changes to your header or footer layout are made only in the JavaScript file, which automatically changes the information in the HTML files.

Jaya Nehru Kumar
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date