xsl-list
[Top] [All Lists]

RE: Can one Use JavaScript to update XSL:Variables

2004-07-29 11:13:59
From: dave frette [mailto:gohabitat(_at_)yahoo(_dot_)com]

But, say I want to perform a browser check via js.
I would probably create an init_ie(), transform_ie(), init_ns(), and
transform_ns().

Basically this code looks really simple and perhaps netscape has
some similar objects to use??

Any suggestions?

I use the following to test for Mozilla -

function isMoz() {
  try {
    var xx = netscape.security.PrivilegeManager;
    return true;
  }
  catch (e) {
    return false;
  }
}

We're drifting OT here (yes, Tommie, I know, but aren't you too busy
just now to attend to it??), but sometimes you can adjust for browser
type without explicitly detecting it.  For example, I have used the
following to get at (CSS) stylesheet rules even though IE and Mozilla
use different names for the same object -

var stylesheet,rules;
stylesheet = document.styleSheets[0];
rules = stylesheet.rules||stylesheet.cssRules;

The first alternative works for IE but is undefined in Moz.  Undefined
evaluates to false in a logic test (gotta love javascript!), and the
second alternative (cssRules) works for any CSS2 compliant browser (one
that uses the specified binding names).  

Cheers,

Tom P