How JavaScript Is Used in hyPub?

This section describes how JavaScript is used in hyPub.

In hyPub, I am suggesting that:

1. You should code common HTML contents that are shared by most of your Book Web pages, like banners, site navigation menu, and promotional items, as JavaScript functions. For example:

function writeMenu(subject) {
   document.write('[ <a href="/index.html">Home</a> | ');
   document.write('<a href="/news.html">News</a> | ');
   document.write('<a href="/search.html">Search</a> ]');

2. You can store those JavaScript functions in a JavaScript file called _hypub.js.

3. Link _hyPub.js to all Web pages in the "head" element as shown below:

<script type="text/javascript" src="_hypub.js"></script>

4. In the "body" of any Web page, wherever you want to insert a special common HTML contents, you just need to call the corresponding JavaScript function as shown here:

<script type="text/javascript">writeMenu("Top");</script>

5. If there is any need to change the common HTML contents in the future, for example, adding a new entry in the menu, all you need to do is to change the code in _hyPub.js. This is the biggest advantage of putting those common HTML contents into a single JavaScript file.

Table of Contents

 About This Book

 Ideas on Publishing Books using XML

 Overview of hyPub - A Simple XML Publishing Tool

 Writing Book Contents in XHTML Source Files

 Transforming Book Source Files with XSL Technology

 Designing Web Page Layouts with Tables

 Controlling Web Page Appearance with CSS

Sharing HTML Codes with JavaScript Files

 What Is JavaScript?

How JavaScript Is Used in hyPub?

 Generating Web Pages with hyPub

 Formatting Printable Documents with XSL-FO

 Generating PDF Documents with hyPub

 Areas of Future Improvements


 Full Version in PDF/ePUB