Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: HTML
Expertise: Intermediate
Jan 22, 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:


<html>
<head></head>
<body>

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

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

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

</body>
</html>

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
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap