Mike,
 
I like it.
 
You have styled the <body> element as an example. Would you need to
style every element in the document using this technique, or would
inheritance deal with the other elements? Sorry if the answer is obvious
but I'm not a JavaScript guru ...
 
Regards,
 
Grant Bailey
 
-----Original Message-----
From: li...@webstandardsgroup.org [mailto:li...@webstandardsgroup.org]
On Behalf Of Foskett, Mike
Sent: Friday, 29 October 2010 12:22 AM
To: wsg@webstandardsgroup.org
Subject: [WSG] A simple IE and JS detection method?



Hi All,

 

I was wondering if you had a little time to comment on the following
technique?

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<!--[if IE]>

  <![if gt IE 8]><html lang="en-gb" class="gtIE8" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml";><![endif]>

  <![if IE 8]><html lang="en-gb" class="IE8" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml";><![endif]>

  <![if IE 7]><html lang="en-gb" class="IE7" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml";><![endif]>

  <![if IE 6]><html lang="en-gb" class="IE6" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml";><![endif]>

<![endif]-->

<!--[if !IE]><!--><html lang="en-gb" class="xIE" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml";><!--<![endif]-->

     <script
type="text/javascript">/*<![CDATA[*/document.documentElement.className+=
" hasJS";/*]]>*/</script>

 

... yada ...

 

<style type="text/css">

body {background:#ccc; color:#000}

.IE8 body {background:#fcc;}

.IE7 body {background:#cfc;}

.IE6 body {background:#ccf;}

.xIE body {background:#fff;}

</style>

 

... yada ...

 

 

Not thoroughly tested I admit but it appears reasonable.

The only failure I can see is detecting IEv6 and JS on because:

 

                .IE6.hasJS {background:#f000}

 

will not work as IE 6 cannot concatenate class names. 

 

What do you think?

 

 

 

Regards,

 

Mike Foskett

http://websemantics.co.uk/

 

 


  _____  

This is a confidential email. Tesco may monitor and record all emails.
The views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited
Company Number: 519500
Registered in England
Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire
EN8 9SL
VAT Registration Number: GB 220 4302 31

*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
******************************************************************* 



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
*******************************************************************

Reply via email to