conditionally change the class of the html document for IE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

conditionally change the class of the html document for IE

Paul DeBruicker
Hi -

Is there a way to use the conditionally  set the class on the <html> tag
in Seaside if the browser is an internet explorer variant?

aRoot if ie7; do:[aRoot htmlAttributes addClass:'ie7'].

sets the class to 'ie7' no matter what browser is accessing the page.

thanks in advance

Paul
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: conditionally change the class of the html document for IE

Boris Popov, DeepCove Labs (SNN)
Paul,

I'd recommend feature detection instead of browser detection; see
http://www.modernizr.com/.

-Boris

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Paul
DeBruicker
Sent: Saturday, December 24, 2011 3:40 PM
To: Seaside - general discussion
Subject: [Seaside] conditionally change the class of the html document
for IE

Hi -

Is there a way to use the conditionally  set the class on the <html> tag
in Seaside if the browser is an internet explorer variant?

aRoot if ie7; do:[aRoot htmlAttributes addClass:'ie7'].

sets the class to 'ie7' no matter what browser is accessing the page.

thanks in advance

Paul
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: conditionally change the class of the html document for IE

Paul DeBruicker
Thanks Boris, your suggestion is a good one.

I'm trying to replicate the head section of the Skeleton
(http://www.getskeleton.com) responsive grid framework example
index.html file.  I was going to put it, and Twitter Bootstrap
(http://twitter.github.com/bootstrap/), Gridless
(http://thatcoolguy.github.com/gridless-boilerplate/) and 320AndUp
(http://stuffandnonsense.co.uk/projects/320andup/) up on squeaksource.
Nick Ager's Seafox has been super handy for this by the way.



Because I'm just making Seaside versions of those CSS frameworks, I
don't want to add modernizr if I can help it.  The relevant part of the
file is:

<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>



But I also don't know that leaving out those declarations will cause any
problems.




On 11-12-24 01:12 PM, Boris Popov, DeepCove Labs wrote:

> Paul,
>
> I'd recommend feature detection instead of browser detection; see
> http://www.modernizr.com/.
>
> -Boris
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Paul
> DeBruicker
> Sent: Saturday, December 24, 2011 3:40 PM
> To: Seaside - general discussion
> Subject: [Seaside] conditionally change the class of the html document
> for IE
>
> Hi -
>
> Is there a way to use the conditionally  set the class on the<html>  tag
> in Seaside if the browser is an internet explorer variant?
>
> aRoot if ie7; do:[aRoot htmlAttributes addClass:'ie7'].
>
> sets the class to 'ie7' no matter what browser is accessing the page.
>
> thanks in advance
>
> Paul
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: conditionally change the class of the html document for IE

Philippe Marschall
2011/12/25 Paul DeBruicker <[hidden email]>:

> Thanks Boris, your suggestion is a good one.
>
> I'm trying to replicate the head section of the Skeleton
> (http://www.getskeleton.com) responsive grid framework example index.html
> file.  I was going to put it, and Twitter Bootstrap
> (http://twitter.github.com/bootstrap/), Gridless
> (http://thatcoolguy.github.com/gridless-boilerplate/) and 320AndUp
> (http://stuffandnonsense.co.uk/projects/320andup/) up on squeaksource. Nick
> Ager's Seafox has been super handy for this by the way.
>
>
>
> Because I'm just making Seaside versions of those CSS frameworks, I don't
> want to add modernizr if I can help it.  The relevant part of the file is:
>
> <!DOCTYPE html>
> <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
> <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
> <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
> <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
> <head>

That's a bit tricky. A possible way may be to create a custom
WAHtmlElement (bad class name BTW) subclass, override #encodeOn: and
then output the string above. And then maybe a convenience method on
WAHtmlRoot to add it (see #meta).

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: conditionally change the class of the html document for IE

Paul DeBruicker
On 11-12-27 09:56 AM, Philippe Marschall wrote:

>> >  <!DOCTYPE html>
>> >  <!--[if lt IE 7 ]><html class="ie ie6" lang="en">  <![endif]-->
>> >  <!--[if IE 7 ]><html class="ie ie7" lang="en">  <![endif]-->
>> >  <!--[if IE 8 ]><html class="ie ie8" lang="en">  <![endif]-->
>> >  <!--[if (gte IE 9)|!(IE)]><!--><html lang="en">  <!--<![endif]-->
>> >  <head>
> That's a bit tricky. A possible way may be to create a custom
> WAHtmlElement (bad class name BTW) subclass, override #encodeOn: and
> then output the string above. And then maybe a convenience method on
> WAHtmlRoot to add it (see #meta).
>
> Cheers
> Philippe


Thanks for pointing me in the right direction.  The reason why the
designers conditionally add classes to the <html> tag is described here:

http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/


I ended up overriding

WAHtmlRoot>>#writeHeadOn: to use my own class to add the <html> tag for
the document if, in my #updateRoot: method I say

aRoot useIEConditionalHtmlElement.

my class just builds the conditional tags and concatenates the
htmlAttributes from Seaside into each tag then gives that string to
WAHtmlDocument to put in the right place.  It seems to work OK.



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside