OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
Advantages to breaking up style sheets?
This page's ID:
10990
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I think, what Emps was getting at was using URL data as a backup to set the stylesheets links, not actually defining the individual CSS rules. I'm doing this on my site (still in development) as well as using cookies. This way the style switching will still work if the user has disabled JavaScript. This is done by using a similar concept to the [b]target=""[/b] workaround in XHTML. You simply code you style links like so: [b]<a href="currentPage.php?styleId=blackOnWhite" onclick="jsStyleSwitchFunction('blackOnWhite'); this.blur(); return false;" >Click To Switch Style</a>[/b] If JavaScript is switched on, the style will be switched on the fly using JavaScript and the link in the [b]href=""[/b] will be ignored due to the [b]"return false"[/b] in the onclick handler. If JS is disabled or switched off, it will reload the page (the [b]href=""[/b] won't be suppressed if there's no JavaScript) sending the [b]$styleId[/b] variable to PHP which then re-writes your [b]<links>[/b] accordingly the same way it would if it read that data from a cookie. The [b]this.blur()[/b] bit is to remove that focus box around the link in IE, which usually disappears when you follow a link to another page but if JS is on, you stay on that page so blurring the focus on that element provides that little bit of extra feedback that you clicked something. Oh and with a bit of creative php work throughout your site, you can use this to maintain styles throughout your pages even if the user has disabled cookies. The other option is just to use cookie-less sessions, but seeing as style data doesn't need to be kept secure, I don't see the point of using sessions for something so simple. Although, seeing as you've setup your site to rely on using the index.php file out of each directory you won't be able to pass variables to PHP throughout the URL unless you re-code all your site links, and I don't think you want to do that. However, having the ability to pass data between pages using the URL is a very handy feature of PHP that you might want to weigh against the benefits of the way you?re currently doing things. Trib: There are many reasons why switching styles that way can be bad. Firstly, it's hard to maintain styles from one HTML page to another. Secondly, switching entire style sheets can be done on the fly, so there's really no point to adjusting individual elements this way unless you want to offer independent control over various elements but again, you have the problems of maintain that state across different pages. Thirdly, most browsers (IE being the exception here) have a built in ability to switch style sheets if you define them correctly using the [b]<link>[/b] tag like so [b]<link href="pathToStyle.css" type="text/css" media="screen, projection, tv" rel="alternate stylesheet" title="My Alternative Style" />[/b]. This means that most non-IE browsers can select a different style without the need for JavaScript at all, which is selected from one of the browsers menus, usually under the view menu. Using JS to alter styles like you suggested means that only JS supporting browsers. Now, while only 2% of the browsers currently being used by web surfers don't support JavaScript, another 8% of surfers have JavaScript disabled, which totals to 10% of your users not being able to use that feature of your website. Furthermore, IE users can't disable JavaScript without a special plugin/addon, so chances are those 8% that disable JavaScript aren't using IE so they could still switch styles if you set up the style switching properly. Heh, can you tell I've been doing a bit of research on this lately? =) [url=http://dracusis.deviantart.com/] [img]http://www.whatever.net.au/~cameron/files/images/ozone/ArtDecoSiggy.gif[/img] [/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »