I have a fullscreen/background slideshow that my client loves that just utterly fails in Internet Explorer 8 and below. I think trying to fix that is way beyond my capabilities right now so I would just like to switch it out for another IE safe background slideshow (less good looking but its something at least) if the browser is IE8 or below.
However, I know that you can switch stylesheets by using
<!--[if IE]>
etc, but the stylesheet relies on some basic html markup within a div (example below) that I do not want to show on the page to internet explorer ...
<ul class="cb-slideshow">
<li><span>Image 01</span><div><h3>Lorem Ipsum Dolor</h3></div></li>
<li><span>Image 02</span><div><h3>Lorem Ipsum Dolor</h3></div></li>
<li><span>Image 03</span><div><h3>Lorem Ipsum Dolor</h3></div></li>
</ul>
how do I remove this if the user is using IE8 or below? I am using a mac so running many tests in IE is not really possible so I am not being lazy in asking.
Do I just have to have different pages or something?
Thanks in advance
If you use conditional comments to set a class on the <html> tag you can avoid having a separate stylesheet:
<!--[if lt IE 7]> <body class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <body class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <body class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <body class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <body class="ie"> <![endif]-->
<!--[if !IE]><!--> <body> <!--<![endif]-->
in your styles just hide the ul : .lte9 .cb-slideshow { display: none;}
see:
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
and
http://misteroneill.com/journal/improved-internet-explorer-targeting-through-body-classes/
To expand on one of the comments, you can put conditional comments anywhere, so you can do this:
<!--[if lt IE9]>// IE-specific slideshow HTML here. <![endif]-->
<!--[if gte IE 9]><!-->// Standard slideshow HTML here (for IE9+ and non-IE browsers) <!--<![endif]-->
Try this:
<!--[if !LT IE 9]><!-->
<p>Not IE 8 and below and all other browsers</p>
<!--<![endif]-->
<!--[if lt IE 9]>
<p>IE 8 and below </p>
<![endif]-->
The first block outputs to all browsers except IE8 and below.
The second block outputs to IE8 and below.
You can define different layout inside <div id="browserid" style="display:none">...</div>-Tags where browserid is one of IE, FF, etc. That makes them invisible by default.
Then you define a javscript function, that is called at onpageLoad and that evaluates the navigator.userAgent property. That contains the client browser name. Depending on that value you change the corresponding 's display-style.
Related
I want to load a .css file if the browser is ie8 or lower and other file if the browser is greater than ie8 or other browser (chrome, safari, etc).
I've read that ther isn't an else in html conditional. And the answers here always says to use something like this:
<!--[if lt IE 9]>
This is less then IE9
<![endif]-->
<!--[if gt IE 8]> <!-- -->
this is all browsers: IE9 or higher, firefox, chrome, etc.
<!-- <![endif]-->
The problem with this is that I don't want to do that only if the browser is greater than 8, I want to do iy if the browser is other than ie also.
How can I do it?
Thanks!
The <!-- --> will ensure that other browsers see the content between it and the next <!--. Notice how the syntax highlighter on Stack Overflow does not highlight the content as an HTML comment — that's how you can tell.
A more common variation that's somewhat shorter:
<!--[if gt IE 8]><!-->
this is all browsers: IE9 or higher, firefox, chrome, etc.
<!--<![endif]-->
Just put your styles before IE conditionals
<link rel="stylesheet" type="text/css" href="your_styles.css">
<!--[if lt IE 9]>
This is less then IE9
<![endif]-->
<!--[if gt IE 8]>
this is for: IE9 or higher
<![endif]-->
I have this html line
I am trying to make it so that when IE reads that line, it changes the "listHr" id to "listhrIE".
I have tried this, in an attempt to switch out the line altogeather, but no luck:
<hr id="listHr"></hr> <!--[if IE]><id="listHrIE"></hr><![endif]-->
I am sure I am doing this wrong. What is the correct way of doing this?
Thanks.
IE tags have a "not IE" component.
<!--[if IE]>
<hr id="listHrIE"></hr>
<![endif]-->
<![if !IE]>
<hr id="listHr"></hr>
<![endif]>
However I'd offer a better way to do it would be to just override the style of listHr when IE is detected
As #Paulie_D pointed out: conditional tags are deprecated and won't work for IE 10 and above. You can use a special meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
to force them to work however this is not recommended. See here: http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx
try these:
<!--[if !IE]><hr id="listHr"></hr><!-->
<!--[if IE]><hr id="listHrIE"></hr><!-->
if you want set this id for some version of IE, you can do this:
greater and equal IE8:
<!--[if gte IE 8]><!-->
less and equal IE8:
<!--[if lte IE 8]><!-->
equal IE8:
<!--[if IE 8]><!-->
You can use IE only conditional tags to detect IE.
Just like:
<!--[if IE ]>
<p>Welcome to Internet Explorer 8.</p>
<![endif]-->
So, In your case you need two things to change ID.
1) Display IE only ID
2) Hide non-IE ID
To apply IE only ID you need following conditional tag code
<!--[if IE ]>
<div id="listHrIE"></hr>
<![endif]-->
To hide non-IE ID you need to add display:none
<!--[if IE ]>
<div id="listHrIE"></div>
<div id="listHr" style="display:none"></div>
<![endif]-->
Now you can style your IE Only ID in way you want and it will only replace listHr when IE detects.
Update: To target IE 10 Use following jQuery: Before using add jQuery Migrate
<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script> This line
to your page<head>
Then add
if ($.browser.msie && $.browser.version == 10) {
$("html").addClass("ie10");
}
I hope this helps :)
I tried using this syntax for IE8 or lower
<!--[if !lte IE 8]>
//my code here
<![endif]-->
But it appears to comment out my code...is this code correct?
I'm not sure if this is valid syntax, but it does work in my case, so I'll post it here:
<!--[if gte IE 9]><!-->
<canvas width="200" height="200"></canvas>
<!--<![endif]-->
This will target IE>=9 and other browsers, and IE<9 will ignore the content.
With this condition the script will be loaded on IE10+ and any other browser that's not IE.
<!--[if (gt IE 8)|!(IE)]><!-->
<!-- put script here -->
<!--<![endif]-->
Hi all : How can i fix the problem of css in ie 7 and ie6 : my divs change possition in those two : www.justcode/housetostay: I will be very glad if i get any help
You can use conditionals to do this.
In your add this code.
<!--[if lt IE 8]>
// Add your IE only stylesheet here
<![endif]-->
This means that if the browser is Less Than IE8 load the stylesheet in the comments.
You can be more specific if you need to.
<!--[if IE ]> - Targets all IE versions from 5.5 up to 9
<!--[if gt IE6 ]> - Targets all IE versions Greater Than IE6
<!--[if IE7 ]> - Targets only IE7
Without using hacks I would suggest using this technique
<!--[if lt IE 7]><html class="ie6"><![endif]-->
<!--[if IE 7]><html class="ie7"><![endif]-->
<!--[if IE 8]><html class="ie8"><![endif]-->
<!--[if gt IE 8]><!--><html><!--<![endif]-->
Then you can add css:
.ie6 .my-div {
}
.ie7 .my-div {
}
Using separate stylesheets for each version of IE is pretty outdated/poor IMO when you can target all versions in your regular single stylesheet
you can read more here: http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
IE<9 does not understand data: URIs, so I'm outputting two different stylesheets: one with normal links to images for IE 8 and below, and one with base64-encoded inline images, for other browsers.
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="/public/themes/url.style.css">
<![endif]-->
<!--[if gt IE 8]>-->
<link rel="stylesheet" type="text/css" href="/public/themes/b64.style.css">
<!--<![endif]-->
Problem: In IE9, I'm seeing a stray --> output on the page. Because it's inside the <head> it appears at the very top of the page. How should I get rid of it?
And I've got it. I did search for valid conditional comments, and found an article telling me to do what I was already doing, but then by chance I came across a by-the-way remark in another answer here which showed me the correct way to do it:
<!--[if lte IE 8]>
<span>This is for IE 7 and below.</span>
<![endif]-->
<!--[if gt IE 8]><!-->
<span>This is for all other browsers (IE 8, and browsers which don't do conditional comments).</span>
<!--<![endif]-->
See the difference: <!--[if gt IE 8]><!--> instead of <!--[if gt IE 8]>-->.