Stop penalising good browsers for IE

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Stop penalising good browsers for IE

Post by psy »

It's tricky enough getting things right in good desktop browsers, let alone responsive designs for tablets and smartphones and IE really annoys me. I don't see why good browsers should be penalised in any way for tweaks added to accommodate IE's shortcomings.

Here's what I do.

Normally in the <head> section of the template I have to add either an IE stylesheet or js or <style> tags for IE or IE version comments, etc. OK for IE but when not IE, it just adds to the download time.

Loading CGExtensions is almost a default. So many modules rely on it. It also has a neat little tag called {cge_isie assign=ie}. I put this above the <__html> tag. Then, when I get to anything in the page template that is IE specific, I put, eg:

Code: Select all

		{if $ie}
	        {literal}
	        <!--[if gte IE 9]>
	            <style type="text/css">
	            ....
	            </style>
	        <![endif]-->
	        <!--[if IE ]>
	            <style type="text/css">
				...
	            </style>
	        <![endif]-->
		{/literal}
        {/if}

That way only IE browsers get the extra IE specific rubbish.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Stop penalising good browsers for IE

Post by Dr.CSS »

Instead of hard coding the styles in the head you can always add IE specific style sheets, create a style sheet called IE8 then use {cms_stylesheet name='IE8'}...
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Stop penalising good browsers for IE

Post by psy »

Good point and very true. The tip was intended to highlight the nice little {cge_isie} tag rather than how to code IE-specific styles and/or javascripts.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: Stop penalising good browsers for IE

Post by blackhawk »

That way only IE browsers get the extra IE specific rubbish.
One more reason to love CMSMS

Thanks for that one!
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: Stop penalising good browsers for IE

Post by Wishbone »

I do the following:

Give an 'ie' class to html if IE

Code: Select all

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

then in the stylesheet, if I need specific IE hacks, I prepend .ie to all definitions that need tweaks:

Code: Select all

.ie .special-more a {
  padding-top: 1px;
}
Post Reply

Return to “Tips and Tricks”