Ronald - Ok, I've cleaned up and documented one method here; I'm sure there are others.
[color=navy]1. To establish our online/offline values, we create a text file called ‘local.js’. This local.js file is kept with your project, has a ‘havewebaccess’ value of ‘0’, and is called like this (items inside of ‘< !—‘ and ‘//->’ are comments)[/color]
< !-- in local.js, havewebaccess = '0' ; //-->
< SCRIPT LANGUAGE="JavaScript" SRC="local.js">
< SCRIPT>
[color=navy]Inside that local file is the line:[/color]
havewebaccess = '0' ;
[color=navy]2. A second text file, ‘online.js’ is located on your website, and is called the same way. When the book starts, it searches for and reads the online.js file and gets the havewebaccess value. That value would be a '1':[/color]
havewebaccess = '1' ;
[color=navy]If the user is online, havewebaccess will be ‘1’. If not online, no error will display, and havewebaccess will remain ‘0’.[/color]
< !-- in online.js, havewebaccess = '1' ; //-->
< SCRIPT LANGUAGE="JavaScript" SRC="http://www.yourdomain.com/library/online.js">
< SCRIPT>
[color=navy]3. We set the ‘1’ or ‘0’ to an Activ global variable. [/color]
< SCRIPT>
window.external.ActivSet('hvaccess',havewebaccess);
< /SCRIPT>
[color=navy]4. When needed, we can access that Activ variable in other pages with:[/color]
< SCRIPT>
var havewebaccess = window.external.ActivGet('{hvaccess}') ;
< /SCRIPT>
[color=navy]5. We build two web files: one has the current information, and resides on your website or online area. It’s called ‘online_update_1.htm’.
The second file is the “not online message”, seen only if havewebaccess = ‘0’; it’s called online_update_0.htm. It is kept with the project files.[/color]
[color=navy]6. We use the Javascript variable ‘havewebaccess’ to choose between two web pages, one online, and a one a local file with the ‘not online’ message. This method creates two different hrefs, depending on the value of ‘havewebaccess’:[/color]
< SCRIPT LANGUAGE="JavaScript">
document.write("< A HREF='online_update_" + havewebaccess + ".htm' >“>< IMG SRC='globe_icon" + havewebaccess + ".gif' border=0 align=middle>Online Update< /A > " ) ;
< /SCRIPT>
[color=navy]7. Bonus: Combine the ‘havewebaccess’ variable with the Activ variable for a valid password to show one of four possible icons:[/color]
[color=navy]globe_icon00.gif ( no password entered, not online)
globe_icon10.gif ( password entered, not online)
globe_icon01.gif ( no password entered, online)
globe_icon11.gif ( password entered, online)
...and implement it like this:[/color]
< SCRIPT LANGUAGE="JavaScript">
document.write("< A HREF='online_update_" + havewebaccess + ".htm' >“>< IMG SRC='globe_icon[={iscorrectpassword}]" + havewebaccess + ".gif' border=0 align=middle>Online Update< /A > " ) ;
< /SCRIPT>
[color=navy]====================================[/color]
There. That’s it. I’m not sure all the code will come through successfully, and I added a space after every ‘<’ to display online here. Be sure to remove them after a cut-and-paste.
You can find some other techniques and tools to help with these sort of things athttp://www.copperfieldpub.com, and there should be more there soon.
best –
roger
rnilsson@copperfieldpub.com
(Edited by Alaska at 2:38 am on Dec. 10, 2002)