[bjslist] Beginners Javascript newsletter - 14-October-2001

  • From: "Beginners Javascript" <bjs@xxxxxxxxxxxxxxx>
  • To: <bjslist@xxxxxxxxxxxxx>
  • Date: Sun, 14 Oct 2001 22:37:11 +0100

Greetings one and all from Beginners Javascript

Before starting I should extend a warm welcome to all the new list members.
For some reason, number of new members subscribing the list has been
increasing rapidly over the last few weeks. That should be enough incentive
for me to get going on the improvements on the site which have been planned

Recent changes on the site include the addition of a tutorial on working
with DATES AND TIMES in the LEARNING section. This, along with a new page in
the PRACTICAL section that deals with DISPLAYING DATES on your web pages,
should provide a solid base for beginners to build on with their own

More new tutorials/articles will be posted online shortly and details of
these will be in the next newsletter.

        Please visit our NEWSLETTER SPONSOR:
        Free UK price comparisons for BOOKs, CDs and DVDs


The big subject of this newsletter is BROWSER COMPATIBILITY. How can you be
sure that the latest fancy piece of Javascript you put onto your site will
actually work for all site visitors? If it is related to a key part of the
site (i.e. navigation), will you lose site visitors because it fails? If so,
what can you do about it?

Hopefully the answers to the following questions will help...

Which browser version should you code for?

The general opinion amongst web professionals seems to be that if you code
for version 4 browsers upwards then you will be catering for the vast
majority of net users. For most sites, this is adequate but don't let that
stop you considering that minority who suffer problems when viewing your
site or, even worse, don't stay and never come back! Always bear in mind
that while a fancy new feature in IE5 may look good on your Windows PC,
someone viewing your site in Netscape 4 on a Mac may have a different

How can you tell which browser and version your visitors are using?

The easiest way involves very little work on your part. Simply sign up for
one of the free counter packages on the net and use the statistics they
provide. I have used http://www.thecounter.com in the past but I believe
they may be charging for some of their services. Another good one is
http://counter.mycomputer.com/ which a friend of mine has been using for a
while without any problems.

It really is very easy to get set up and you only need to add a few lines of
code to the main home page of your site to start gathering information on
your visitors like browser name, version, operating system, screen
resolution. All of these help you to be sure that your site is being seen at
it's best by most (if not all) of your visitors.

How to identify different browsers and versions

The partial script shown below can be used to set up some variables showing
the browser type and version. These variables can be used later in your page
as a way of executing conditional code (i.e. only if IE4+).

<script language=Javascript>
   NS4 = (document.layers);
   IE4 = (document.all);
  ver4 = (NS4 || IE4);
 isMac = (navigator.appVersion.indexOf("Mac") != -1);

It works very simply by setting each variable to either TRUE or FALSE based
on whether the relevant code works or not! For example, "document.layers"
will only work in Netscape browser of version 4 upwards but will fail
gracefully in Internet Explorer! Later on in your page simply put an IF
statement around the conditional parts to prevent nasty errors or warnings
from incompatible browsers!

<script language=Javascript>
  if (ver4)
        // do something that only version 4 browsers can handle


All suggestions for topics/tips to be covered are gratefully received. The
current list includes frames, forms plus an introduction to Javascript
classes but if you have something more urgent that you would like to see
then just drop me a line.


        Please visit our NEWSLETTER SPONSOR:
        Free UK price comparisons for BOOKs, CDs and DVDs

Other related posts:

  • » [bjslist] Beginners Javascript newsletter - 14-October-2001