October 1999
Intermediate to advanced
480 pages
14h 47m
English
The user preferences have been changed. The time has come to see how to convert those recorded changes into visual realities. The process isn’t long, but the details can get a bit sticky. It’s probably obvious by now that the information will come from information stored in a cookie. That extracted information is used in three ways.
As a URL for a background image
As URLs and display text for links
As part of a stylesheet declaration for font family and size
We’ll encounter each use as we go. For now, soak in the code for dive.html, coming right up in Example 7.2.
Example 7-2. dive.html
1 <HTML> 2 <HEAD> 3 <TITLE> 4 Your Take-A-Dive Links Page 5 </TITLE> 6 <SCRIPT LANGAUGE="JavaScript1.2" SRC="cookies.js"></SCRIPT> 7 <SCRIPT LANGUAGE="JavaScript1.2"> 8 <!-- 9 10 var newsNames = new Array(); 11 var indexNames = new Array(); 12 13 function getAttributes() { 14 var htmlStr = GetCookie('htmlPrefs'); 15 if (htmlStr == null) { 16 alert('Welcome. You must first set your user preferences.' + 17 'Please choose OK to load the User Settings page.'); 18 self.location.href = 'prefs.html'; 19 } 20 var htmlArray = htmlStr.split('-->'); 21 for (var i = 0; i < htmlArray.length; i++) { 22 var tagInfo = htmlArray[i].split('='); 23 if (tagInfo[0] != "") { 24 if (tagInfo[0].indexOf('newsNames') == 0) { 25 newsNames[newsNames.length] = tagInfo[1]; 26 } 27 else if (tagInfo[0].indexOf('indexNames') == 0) { 28 indexNames[indexNames.length] = tagInfo[1]; 29 } 30 else { eval(tagInfo[0] + ' = "' ...Read now
Unlock full access