W3C home > Mailing lists > Public > www-style@w3.org > September 1998

Script for selecting sheets

From: Russell Pearson <R.Pearson@art.derby.ac.uk>
Date: Wed, 23 Sep 1998 15:43:02 +0100
Message-Id: <l03130301b22e73743b10@[193.60.146.202]>
To: www-style@w3.org
Hi,

Can anyone help on this one? I'm using the following JavaScript to select
between two stylesheets- 1 for Navigator and 1 for Explorer:

<script language="JavaScript">
<!--
// this script determines whether the user's browser
// is  IE4, or Netscape 4, and loads a different
// style sheet for each; for other browsers,
// it does nothing
var browser=navigator.appName;
var version=navigator.appVersion
var ver1=version.substring(0,1)
var ver2=version.lastIndexOf("MSIE")
var ver3=version.substring(ver2+5,ver2+6)

 function itsNetscape() {
 document.write('<LINK REL=StyleSheet HREF="../../stylesheets/n4direct.css"
TYPE="text/css">') }
function itsMsie() {
  if (browser == "Microsoft Internet Explorer")
    ieVersion()
     }
     function ieVersion(){
      if (ver1 >= 4)
         document.write('<LINK REL=StyleSheet
HREF="../../stylesheets/direct.css" TYPE="text/css">')
}
 if ((browser == "Netscape") && (ver1 >= 4)){  itsNetscape() } else{
itsMsie() }
// --></script>


This is creating problems...
On a Mac using IE4 it's fine, but if you try and re-size the browser using
Netscape it crashes the machine. Furthermore, using refresh on IE4 on NT
causes the layout to go haywire (I've yet to test Netscape on a  PC).

Has anyone any solutions/alternatives please?


Russell Pearson,
Media Delivery Specialist,
School of Art & Design,
University of Derby,
Britannia Mill,
Mackworth Road,
Derby.
DE22 3BL

R.Pearson@art.derby.ac.uk

www
Online Training: http://art.derby.ac.uk/direct/ (Work in Progress)
CyberForum:   http://art.derby.ac.uk/  (Previous Project)

Tel:01332 622222 x 4080
Fax:01332 622725
Received on Thursday, 24 September 1998 05:00:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:56 GMT