October 1999
Intermediate to advanced
480 pages
14h 47m
English
The brains of the application lie in the header file named
nav.html. In fact, the only other place
you’ll see JavaScript is in the results pages manufactured on
the fly. Let’s have a glimpse at the code. Example 1.1 leads the way.
Example 1-1. Source Code for nav.html
1 <HTML> 2 <HEAD> 3 <TITLE>Search Nav Page</TITLE> 4 5 <SCRIPT LANGUAGE="JavaScript1.1" SRC="records.js"></SCRIPT> 6 <SCRIPT LANGUAGE="JavaScript1.1"> 7 <!-- 8 9 var SEARCHANY = 1; 10 var SEARCHALL = 2; 11 var SEARCHURL = 4; 12 var searchType = ""; 13 var showMatches = 10; 14 var currentMatch = 0; 15 var copyArray = new Array(); 16 var docObj = parent.frames[1].document; 17 18 function validate(entry) { 19 if (entry.charAt(0) == "+") { 20 entry = entry.substring(1,entry.length); 21 searchType = SEARCHALL; 22 } 23 else if (entry.substring(0,4) == "url:") { 24 entry = entry.substring(5,entry.length); 25 searchType = SEARCHURL; 26 } 27 else { searchType = SEARCHANY; } 28 while (entry.charAt(0) == " ") { 29 entry = entry.substring(1,entry.length); 30 document.forms[0].query.value = entry; 31 } 32 while (entry.charAt(entry.length - 1) == " ") { 33 entry = entry.substring(0,entry.length - 1); 34 document.forms[0].query.value = entry; 35 } 36 if (entry.length < 3) { 37 alert("You cannot search strings that small. Elaborate a little."); 38 document.forms[0].query.focus(); 39 return; 40 } 41 convertString(entry); 42 } 43 44 function convertString(reentry) { 45 var searchArray = reentry.split(" "); 46 if (searchType ...Read now
Unlock full access