VB.NET: dynamic css

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?
 
G

Gregory A. Beamer

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 |
*********************************************
 
A

Andrew Morton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top