Change CSS file through dropdown (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets



Message


Mane -> Change CSS file through dropdown (7/14/2005 17:02:56)

Is there a way to make a dropdown list change the css file for the page?




Tailslide -> RE: Change CSS file through dropdown (7/14/2005 18:05:25)

You could use a styleswitcher ( a bit of javascript) to change the stylesheets - this could be activated any way you want - clicking on links, dropdowns whatever.

Have a look at Paul Sowden's original at Alistapart and there's a slight twist on the theme here also at Alistapart (Invasion of the Body Switcher)




bobby -> RE: Change CSS file through dropdown (7/14/2005 18:08:31)

I played with an inline stylesheet (not a .css file, but the style declared on each page as an include file) and used ASP to dynamically alter it...

I used a database and cookies...

It wasn't very efficient or easy, but it did the trick and allowed visitors to almost completely customize their surfing experience on that site...





Tailslide -> RE: Change CSS file through dropdown (7/14/2005 18:13:20)

The good thing about using dbs/PHP/ASP is that all the "work" is done server-side so it doesn't matter what the user has in the way of plugins, javascript whatever. The good thing about the Javascript styleswitchers is that it's easy to implement and quite efficient.

The absolute best way if you can work it would be to have a JS styleswitcher that works unless the user has JS switched off (about 10% do) and then it would default to the server-side styleswitcher instead - best of both worlds then.

Just... don't ask me how... never got around to doing it yet!




yogaboy -> RE: Change CSS file through dropdown (7/15/2005 6:34:21)

If you are using XHTML you could use the @import to plop (that's a technical phrase) a new style sheet over the top of the main one. I use the stuff below to make sure IE lines up properly, but you could easily change it for a select menu.

This goes in the head tags
<link rel="stylesheet" href="links3.css" type="text/css" />
<!--#include virtual="/includes/slctBrowser.asp"-->

and this is the slctBrowser code
<%
select case browser
case "IE"
Response.write "<style type='text/css'>@import url('/linksie.css');</style>"
end select
%>




yogaboy -> RE: Change CSS file through dropdown (7/15/2005 6:40:08)

Forgot this bit - put it right at the top just after the doc declaration. I use it to find out whether they're using IE or not, but there's also a javascript detection bit that I never use, don't know how good it is?????

<%
'declare variables
Dim browserdetect, browser, version, majorver, minorver, platform, tables, cookies, javascript
' create an instance of the Browser Capabilities component
Set browserdetect = Server.CreateObject("MSWC.BrowserType")
browser=browserdetect.Browser
version=browserdetect.Version
majorver=browserdetect.Majorver
minorver=browserdetect.Minorver
platform=browserdetect.Platform
tables=browserdetect.Tables
cookies=browserdetect.Cookies
javascript=browserdetect.JavaScript
%>




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875