I'm building a mobile-first site, and I'm stuck on the menu.
Everything works great in Firefox, Chrome, Safari & Opera; as you can see here.
But ofcourse, the pathetic excuse of a browser abortion, internet explorer, doesn't support media queries. So I started browsing around and found the javascript solution for the Idiot Experience media query problem. (See what I did there?) Respond - by scottjehl
So I quickly implemented the script and grabbed my cake to start celebrating this victory over the oozing scrotum of the browser world. But alas, the script did absolutely nothing, and I slipped back into my microsoft induced depression.
I implemented the script into my header like so:
<!--[if (lt IE 9) & (!IEMobile)]>
<script type="text/javascript" src="js/respond.min.js"></script>
<![endif]-->
And I added the comment before closing my mediaquery.
/*/mediaquery*/
Anyone got any idea what might be going wrong here?
Solved it.
Had to do with my DOCTYPE.
Wasn't supporting older versions of IE.
This code fixed it:
<!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]-->
Related
Could somebody help me out read this?
<!--[if gt IE 8]><!-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!--<![endif]-->
<!--[if lte IE 8]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<![endif]-->
I understand that if current browser is greater than ie 8, we end up using the 1.9.1 and if current browser is less than or equal to 8, we end up with 1.7.2
I've got a few questions here;
First one is what if the browser is not even IE? Chrome for example.
How does the above header code gets to include JQuery at all. Obviously it does, but can't see how. Condition is only addressing IE. Isn't it?
Secondly, I am confused on the snytax;
<!--[if gt IE 8]><!--> part looks different than <!--[if lte IE 8]> part. the extra <!--> in the former confuses me.
Here is where I got the snippet from;
http://bombdiggitydesign.com/crisp-2/Crisp-cool/index.html
It somehow loads the JQuery for me ( I'm using Chrome ).
When I examine the viewsource:, I see this
<!--[if gt IE 8]><!-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="assets/js/jquery-1.9.1.min.js"><\/script>')</script>
<!--<![endif]-->
<!--[if lte IE 8]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<![endif]-->
and in this, only the http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js is clickable in chrome's view. So, chrome somehow makes it thru the <!--[if gt IE 8]><!--> condition.
Obviously, it works but I am confused as to how.
For your fist question, that's the specialty of IE conditional comments.
For your sencond question,
<!--[if gt IE 8]><!--> //COMMENTS ENDS
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>
<!--<![endif]--> //COMMENTS ENDS
This is nothing just comments for their convenience (to be precise READABILITY). But the jQuery 1.9.1 will work in all browsers.
However your jQuery 1.9.1 will be overridden by the jQuery 1.7.2, only in IE <=7 browsers.
FYI: In Internet Explorer 10 HTML conditional comments are not supported when the page is in standards mode (document mode 10)
Hope you understand.
Those conditionals are wrong, that's why. Go here to see how they should be structured: http://www.quirksmode.org/css/condcom.html
You're using wrong "IE Hacks", so your code is invaild.
Here is an article that will help you out:
To Article
conditional comments are ms proprietary markup...so only trident (ie) will read conditional comments....and that's only up to ie10...although you can still use conditional compilation.
idk the exacts about how/what other engines do when they come across them...you're saying chrome sees them...i guess that makes sense...as long as no one is rendering/do anything to it, except for the browsers you are targeting with it.
you're conditional statements are invalid, as the other two gents have pointed out. if you correct the syntax, they'll work just fine.
I am very puzzled with this one. I thought it was going to be a five minutes problem, became a three days one.
This is the deal.
I have an MVC 3 application. It renders perfect in all browsers but IE 9 simply doesn't show anything.
Now, check this out. Very important.
When i open the "browser's debuggers" for Firefox (Firebug 1.11.1) and IE9 (F12), i found something weird.
Check my attachments...
When i right click on both browsers and ask for View Source, i can see the whole expected HTML there, but in the "debuggers", IE9 shows the body empty (I guess what's actually showing is the final result from rendering?).
Very Important, check in the View Source screenshot, this...
<!DOCTYPE html>
<!--[if lt IE 8 ]><html lang="en" class="no-js ie ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="no-js ie"><![endif]-->
<!--[if (gt IE 8)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<title>LogOn</title>
.....
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script type="text/javascript" src="/Scripts/standard.js"></script>
<!--[if lte IE 8]><script type="text/javascript" src="/Scripts/standard.ie.js"></script><![end if]-->
....
</head>
I don't even know what to ask specifically here. Are these [if lte...] statements work in every browser? I don't have a clue what's going on here guys.
Anyone that has walked thru the valley of death before???
Thanks
EDIT:
I am using a template that i purchased on themeforest.net. Their sample (pure HTML) works perfectly fine in all browsers. They also look the same to my code (the header part of course) when i click on ViewSource. That's why i am assuming there is something to do with how i am rendering from MVC.
Answering my own question....
It had to do with this line
<!--[if lte IE 8]><script type="text/javascript" src="#Url.Content("~/Scripts/standard.ie.js")"></script><![endif]-->
It was rendered incorrectly. Now it's all good.
I'm using Require JS in my project which is loading jQuery and some other JavaScript files that are relevant for the entire site and all browsers.
However, I need to use some conditional jQuery on Internet Explorer 7 & 8, I've tried putting this in the head of the page and the script doesn't seem to be able to find jQuery, I'm presuming this is because it's getting loaded before jQuery.
<script data-main="/#ViewBag.ScriptsFolder/main" src="/scripts/require.js" type="text/javascript"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="/Scripts/ie.js"></script>
<![endif]-->
Is there any way to rectify this? I'm also trying to load Selectivizr in this way which isn't working because of the same problem.
Thanks
You could use a conditional IE-specific class on the html element, then checking for it and loading the IE dependencies inside your existing main script. So, the top of the document would look like:
<!--[if lt IE 7]> <html class="ie lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="ie lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="ie lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="ie"> <![endif]-->
<html>
And then inside main.js, you could use:
if ($('html.lt-ie9').size()) {
require(['/Scripts/ie'], function(ieScript) {
// ... do stuff
});
}
You can't use the method you've described because require.js looks for a single data-main attribute to specify the 'entry point' - any subsequent calls to require should be done in Javascript.
I found out that my javascript-intensive web site doesn't work reliably (or at all) in IE9.
It works, (usually, but not always) with the compatibility mode meta tag in the header, but I just want to build a page that I know will work well in IE9 and then have the usual page redirect to it when IE9 is detected. The usual page is fine in IE 7 and 8 (and every other browser I've tried it on).
Can anyone give me some javascript that will do that? Thank you!
Here's my usual page:
http://ianmartinphotography.com/test-site/test/
The simplest way would be to use IE Conditionals.
Note: IE10 and beyond have removed support for this feature. For modern browsers the widely accepted way of conditionally displaying content for compatibility purposes is using feature detection. Modernizr is a popular library built for handling feature detection.
For example:
<!--[if IE 9]>
<script type="text/javascript">
window.location = "http://www.ie9version.com";
</script>
<![endif]-->
Examples from the conditional site:
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
<!--[if true]>You are using an <em>uplevel</em> browser.<![endif]-->
<![if false]>You are using a <em>downlevel</em> browser.<![endif]>
<!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->
<script LANGUAGE="JavaScript">
<!--
if( navigator.appName.toLowerCase().indexOf("microsoft") > -1 ||
navigator.userAgent.toLowerCase().indexOf("msie") > -1 ) {
window.open("http://www.pobox.com/~qed/windoze.html", "Windoze",
"dependent=no,titlebar=no,scrollbars=yes" );
}
// Paul Hsieh
// qed at pobox dot com
// -->
</script>
Source: http://www.cexx.org/snicker/nomsie.htm
It's possible to load a script only in IE with conditional comments
<!--[if lte IE 7]>
<script type="text/javascript" src="somescript.js"></script>
<![endif]-->
but what if I don't want to load it in IE lte 7 (but still need it in all other browsers)?
Any simple solutions?
P.S. I have a problem with SyntaxHighlighter - too many code slows IE7 down and since I'm short of time, I decided just to turn it off in IE7 for now.
This post says you can use the ! (NOT) operator like [if !IE]
<![if !IE]>
<script type="text/javascript" src="somescript.js"></script>
<![endif]>
<!--[if gte IE 7]>
<script type="text/javascript" src="somescript.js"></script>
<![endif]-->
<!--[if !IE]>
<script type="text/javascript" src="somescript.js"></script>
<![endif]-->
This syntax works good (the script wouldn't be commented in firefox, chrome and so on):
<!--[if !IE]><!-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!--<![endif]-->
You could try detecting the browser server-side and then echo the appropriate script includes.
The following has an example on simplistic browser detection in PHP:
http://www.php-scripts.com/20050912/12/
Since conditional statements are not Working in IE (10,11) and only IE(11) is supported by Microsoft and if anyone is still looking at running IE specific JavaScript then this code still works tested in IE(11), and non IE browsers(Chrome,Firefox,Edge).
<script type="text/javascript">
if(/MSIE \d|Trident.*rv:/.test(navigator.userAgent))
{document.write('<script src="../nolng/js/ex1IE.js"><\/script>');}
else
{document.write('<script src="../nolng/js/ex1.js"><\/script>'); // for Chrome,Firefox,Edge}
</script>
I used the examples shown here and elsewhere, and it is really frustrating to see how many places this code example is messed up. Turns out the answer is simple, IE has special 'conditionals' like [if IE], but other browsers need comments to work with the 'conditionals'.
For example, since JQuery 2 doesn't work with IE8, you can do something like this
<!--[if IE ]> (following is only visible to IE)
<script src="./js/lib/jquery-1.6.1.min.js"></script>
<![endif]-->
<!--[if !IE]>--> (extra comment - only visible to non-IE)
<script src="./js/lib/jquery-2.1.1.min.js"></script>
<script src="./js/lib/jquery.mobile-1.4.5.min.js"></script>
<!--<![endif]-->
I have verified the above works in Firefox, Chrome, IE8, Dolphin mobile, and Chrome mobile. You can also specify version. For example, less than IE 9 would be: <!--[if lt IE 9 ]>
For a detailed explanation, check out http://www.sitepoint.com/web-foundations/internet-explorer-conditional-comments/