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

Selecting Stylesheets

From: R.Pearson <R.Pearson@art.derby.ac.uk>
Date: Wed, 23 Sep 1998 16:00:36 +0100
To: www-style@w3.org
Message-ID: <0570b17.199809231558.022D17B8@art.derby.ac.uk>

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")
     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 and Design
University of Derby.

e-mail: R.Pearson@art.derby.ac.uk
Tel 01332 622222 ext 4080
Received on Wednesday, 23 September 1998 11:22:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:48 UTC