VB.NET: dynamic css

  • Thread starter Thread starter Mike J.
  • Start date Start date
M

Mike J.

Hi, I have a web project in VB.NET 2005. I want to detect the user's web
browser and version, then make a change to the CSS based on which version of
IE, 6 or 7. I have a javascript function pageLoad that works to detect the
version but I'm still trying to get the css changed from that point. Does
anybody here know how to do this?
 
VB.NET is inconsequential here, as you are doing this in JavaScript. Your
stylesheet probably looks something like this:

<link id="cssFile" href="ie.css" type="text/css" rel="stylesheet">

You then have a test that says it is Firefox, not IE. Just do this:

document.getElementById('cssFile').href = 'firefox.css';

I typed this in freehand, so fix it if necessary. The basic concept works.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
 
Mike said:
Hi, I have a web project in VB.NET 2005. I want to detect the user's
web browser and version, then make a change to the CSS based on which
version of IE, 6 or 7. I have a javascript function pageLoad that
works to detect the version but I'm still trying to get the css
changed from that point. Does anybody here know how to do this?

No need: you can make IE do things that other browsers will ignore without
fiddly CSS hacks:

http://www.quirksmode.org/css/condcom.html

So if the user has Opera set to pretend to be IE in the user-agent string,
it still works.

Andrew
 
Back
Top