Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Browser based CSS switcher with XHTML 1.0
Old 01-12-2008, 12:59 AM Browser based CSS switcher with XHTML 1.0
Novice Talker

Posts: 12
Trades: 0
Hey guys, I have been working hard on my first website and have finally hit a snag that I have not been able to fix. I originally had a small Javascript that would load a certain style sheet based on the browser type, and I got it to work fine. One of the next things I did was validate my page in HTML 4.0, which worked out great. I intented to have the page be XHTML 1.0 Strict valid so I went to work on that. I got the validator to show only two errors, both of which involved my stylesheets. I have been unable to get these stylesheets to work with XHTML 1.0, while the rest of the page is working as intented. I am hoping you guys have a solution to the problem or another method of switching the style sheets based on browser that would allow this to work. Here is the code for my head.
Quote:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>


<meta name="description" content="Starcraft and Starcraft 2 News, Maps, Images, Videos, Mods, Forums, Chat and more!" />
<meta name="keywords" content="Starcraft Starcraft2 Maps Editors Screenshots Art Wallpapers Videos Forum Strategies Mods Hacks Chat News Updates" />
<meta name="robots" content="index, follow" />
<meta http-equiv="content-type" content="text/html" />

<title>Starcrafted, your source for Starcraft and Starcraft 2 maps, downloads, media, news, and more!
</title>

<script type="text/javascript">
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;

if (browser_type == "Microsoft Internet Explorer"){
document.write("<link rel="stylesheet' type='text/css' href='layoutstyleie.css' />");
}

else {
document.write("<link rel="stylesheet' type='text/css' href='layoutstyleother.css' />");
}

</script>
</head>
After I tried validating it again before i posted this it came up with 6 errors but they all involve the xml I tried to use to fix this problem with the stylesheets or the links to the stylesheets themselves. I will be contining my search for a solution after a good night's rest but I wanted to see if anyone on this lovely forum might have a solution for me, thanks for the help!
MikeRoweforpres is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-12-2008, 03:58 AM Re: Browser based CSS switcher with XHTML 1.0
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
We would need to know what the errors are before they can be fixed.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-12-2008, 04:05 AM Re: Browser based CSS switcher with XHTML 1.0
Novice Talker

Posts: 12
Trades: 0
Ahh sorry about that, here are the errors when I try to validate. To add, I have never used XML before so when I tried using some XML solutions I found online I may have botched that as well. Oh well this is a learning process

Line 24, Column 83: character ")" not allowed in attribute specification list.
…ext/css' href='layoutstyleie.css' />");

Line 24, Column 83: document type does not allow element "link" here
.…ext/css' href='layoutstyleie.css' />");

Line 24, Column 84: end tag for "link" omitted, but OMITTAG NO was specified
.…xt/css' href='layoutstyleie.css' />");

Line 28, Column 86: character ")" not allowed in attribute specification list
.…/css' href='layoutstyleother.css' />");

Line 28, Column 86: document type does not allow element "link" here
.…/css' href='layoutstyleother.css' />");

Line 24, Column > 80: XML Parsing Error: attributes construct error
.…='text/css' href='layoutstyleie.css' />");…

Line 24, Column > 80: XML Parsing Error: Couldn't find end of Start Tag link line 24
.…='text/css' href='layoutstyleie.css' />");…

Line 28, Column > 80: XML Parsing Error: attributes construct error
.…='text/css' href='layoutstyleother.css' />");…

Line 28, Column > 80: XML Parsing Error: Couldn't find end of Start Tag link line 28
.…='text/css' href='layoutstyleother.css' />");…

Last edited by MikeRoweforpres; 01-12-2008 at 04:08 AM..
MikeRoweforpres is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 04:33 AM Re: Browser based CSS switcher with XHTML 1.0
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok!

Now do we get a URL so we can actually SEE the code?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-12-2008, 10:24 AM Re: Browser based CSS switcher with XHTML 1.0
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Why bother with scripting the stylesheets when all you really need is conditional comments in your HTML to target the most egregious offender - IE. All other more standards-compliant browsers get a single stylesheet.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 01:21 PM Re: Browser based CSS switcher with XHTML 1.0
Novice Talker

Posts: 12
Trades: 0
Here is the url of the website - www.starcrafted.org - If you click any of the links itll take you to what the page would look like with working css (aside from a couple changes I need to make to one div). Im only trying to validate the index right now before I convert the rest of the site. I am unfamiliar with what conditional statements are and how they work, how would I go about using this method to implement my stylesheets? Thanks alot for your help guys.
MikeRoweforpres is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 01:33 PM Re: Browser based CSS switcher with XHTML 1.0
Novice Talker

Posts: 12
Trades: 0
Well guys, I figured out what conditional comments were through a little research and it did the trick! My stylesheets load properly and my index page validates as XHTML 1.0 strict Thanks for your help. I will be posting here alot more once I get my site nice and clean.
MikeRoweforpres is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 01:42 PM Re: Browser based CSS switcher with XHTML 1.0
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Yay ! Glad you got it sorted out.. and it's a lot easier than scripting the stylesheets
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Browser based CSS switcher with XHTML 1.0
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33028 seconds with 12 queries