eBook Scripts
highlighting hits in the search results

 
Home Design Tips Scripts Templates/Translations


Highlighting Hits In The Search Results

Overview

This example explains how to highlight the search hits within the page content of your E-Book.


Requirements
Instructions
  1. Create a file called hilite.js and place in your source file. This file can be created using Notepad or any other plain text editor.

    Please note: If using Notepad on a version of Windows prior to Windows XP, when you save in Notepad, be sure to place the file name in quotes on the Save As dialog box, i.e. "hilite.js" otherwise Notepad will add .txt to the end of the name (giving a file name of hilite.js.txt). If using Notepad on Windows XP, this workaround is not necessary.

    hilite.js should contain the following:


  2. EITHER

    If you use a CSS (cascading style sheet) for your e-book pages, you will need to add the following to your .css file:

    OR

    If you do not use a CSS file for your e-book pages, you will need to add the following to the <HEAD> ....</HEAD> section of every page in your e-book (if you forget to include a page, the hits won't be highlighted on that page).

    CHANGING COLOR:
    In both cases above, the #FFFF00 indicates the color to highlight hits (in this case, yellow). You can use a different color, for example from this color chart if you prefer.

  3. Now you need to add the following to the <BODY>... </BODY> section of every page.

  4. If you want the hits to be highlighted on the About or Table Contents pages, you'll need design your own pages, and select them as "My Own Page" (in Edit System Pages in the compiler), and also include the alterations described above, in both of these pages.

  5. If you want the hits to be shown on the search results page itself, you'll need to customize the search results page, and include the alterations described above, in your search template page.

  6. To summarize how this works:

    • hilite.js is a JavaScript file that scans the current page based on the most recent search, and highlights words matching the most recent search criteria. When it finds a matching word, it sets the CSS style of the word to aebsehit.

    • The <STYLE>...</STYLE> changes (or modifications to your CSS file), cause any areas of style aebsehit to be colored yellow (or your chosen color).

    • You must include both elements on all pages. If you omit either element from any of the pages, the search hits will not be highlighted on that particular page.

  7. The Help which comes with version 5.0x, itself uses this feature to highlight search hits. A screen shot of this (after searching for password and security) is shown below.

    Highlight Hits


Notes
  1. This script has been tested with Activ E-Book Compiler versions 5.00 (5.00 is the latest version - beta release - at the time of writing). It is possible that changes might be required for e-books made with subsequent versions.

  2. This script will not work with versions of Activ E-Book Compiler prior to 5.00.






 

Home: eBook Code



Other Sites about eBooks

EBookApprentice.com
Learn about eBook publishing

EBookCompiler.com
Software to create your own eBooks

CoverFactory.com
Create eBook Covers with ease

EBookPower.com
Add multimedia to your eBooks

EBookFriends.com
Discuss eBooks

EBookInterviews.com
Read about other eBook authors' experiences

EBookSubmit.com
Learn about eBook marketing

EBookJungle.com
Searchable directory of eBooks



Related Links

Internet Marketing
 Learn Marketing
 Marketing Tactics

Promotion Links
 Email Marketing
 Increase Traffic
 Press Releases
 Search Engines
 SEO Downloads

Web Site Building
 Accept Credit Cards
 Affiliate Programs
 Domain Names
 Setup Internet Store
 Web Design Software
 Web Design Tutorial
 Web Hosting
 Webmaster Tools

 

 
Disclosure: Advertising Link(s): Our company may receive a payment if you purchase a product/service after following this link.

Disclosure: Our company's websites' content (including this website's content) includes advertisements for our own company's websites, products, and services, and for other organization's websites, products, and services. In the case of links to other organization's websites, our company may receive a payment, (1) if you purchase products or services, or (2) if you sign-up for third party offers, after following links from this website. Unless specifically otherwise stated, information about other organization's products and services, is based on information provided by that organization, the product/service vendor, and/or publicly available information - and should not be taken to mean that we have used the product/service in question. Additionally, our company's websites contain some adverts which we are paid to display, but whose content is not selected by us, such as Google AdSense ads. For more detailed information, please see Advertising/Endorsements Disclosures

About/Terms Of Use     Privacy     Site Map     Advertising/Endorsements Disclosures

Copyright © 2002-2009, Answers 2000 Limited