I wish to incorporate some pages on the net into my ebook.
I would like to check whether an active internet connection exists before attempting to access these pages.
Is there a way of checking for internet connection and then diverting to an appropriate error page if connection is not found...rather than end up a page not available message?
Include a reference in your ebook to a .js file living on your web server; the js. file contains a variable like "AreWeOnline = 1;".
Your book starts out with the same variable set to '0'. It checks the .js file online. If you are not online, it will not throw an error or 404 page. If you are online, the 'AreWeOnline' value is 1.
Base all your decisions thereafter on the '0' or '1'. Your images, for instance, can be named 'WebLinkGlobe0.jpg' (a disabled gray web link image) and 'WebLinkGlobe1.jpg' ( a normal image ), and you can swap between images based on that value.
Thanks Roger....thats an interesting suggestion which I will make use of.
However my request was on a slightly different topic-
I wanted a means of checking whether the ebook user had an active internet connection at the time of using the ebook not whether or not the author was online. Any ideas on this problem?
The author is not involved here. The bit o'script is in the finished ebook, and, upon opening, checks if the user (reader) has internet access.
In order for the book to check if you have 'an active internet connection', it goes online. It seeks some kind of web connection. Just like you would with your browser.
If you want the information to persist, as in, 'Yes, the user had access when he opened the book the first time', you still need to test for the connection, and then save that value in, say, an .ini file.
You still need some way to retrieve a value, indicating yea or nay.
With any business, it is up to the individual owner of said business to ensure the success of the business. You may make more or less than any sample figures or results that might be quoted on our web sites or other publications. All business involves risk, and many businesses do not succeed. Further, Answers 2000 Limited does NOT represent that any particular individual or business is typical, or that any results or experiences achieved by any particular individual/business is necessarily typical.