IE8 documentMode always 'quirk mode' - javascript

I'm trying to print a message to the user when he is using an IE version bellow IE8. To test it I enabled the Document Mode 8. But when I ask for the Document Mode in javascript I always receive the 'quirk mode: 5'
document.documentMode;
Does anyone know why?
Here is the beginning of my specification:
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
...
SOLVED:
I used the user-agent nevertheless and checked for the 'trident/4.0' tag which is displayed only in IE8

There are a couple of things that can force IE into QuirksMode the most obvious two are
A Missing, malformed or dated Doctype see the table near the bottom of this page for a comprehensive guide to which doctypes will trigger quirksmode
Anything on the page before the DocType, IE insist on the DocType being the absolute first thing to appear in the file or it assumes no DocType and revers to QuirksMode

Use this meta tag in your page head section...
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
It'll finalized your document mode.

Related

parsing html using Jsoup - returned document with robots meta tag

My problem is when I am using jsoup lib for parsing a specific url, it has been great till one day my parsing has corrupted, the document that has returned had some few tags which was not anything like the old document, it had meta tag named "ROBOTS".
An example of the header in the response:
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="initial-scale=1.0" />
</head>
My question is, how do you think I can overcome this block? Tried using several other libraries which parse javascript as well, but it wasnt helpful and resulted the same, maybe I didn't use it right.
(I have learnt that the meta tag robots was made for preventing bots, initially for search engines, how can I bypass this behavior? How can I act like a regular every-browser client?)
You didn't explicitly state this in your answer, but I'm assuming Jsoup is being sent different HTML than what your browser sees. In that case, you probably need to set the user agent header so Jsoup looks like your browser.

How to create site which in IE=11 uses edge mode and in others IE use IE=6

This is really hard question. I need to open page in IE11 with edge mode and in others IE (11,10,9,8) i need to run page with IE6 mode.
I tried to use
<meta http-equiv="X-UA-Compatible" content="IE=edge,IE=6" />
tried to use
<!--[IF LT IE 10]>
<meta http-equiv="X-UA-Compatible" content="IE=6" />
<![ENDIF]-->
even tried to change meta attribute with javascript and nothing works.
pls help
I would strongly advise not forcing IE10 through IE8 to behave as though they are a seriously non-standards-compliant browser from 2001.
But if you really have a case for needing to do that, I expect the venerable (and otherwise-to-be-avoided) document.write could do it for you:
<head>
<script>
if (thisIsIE()) {
document.write(
'<meta http-equiv="X-UA-Compatible" content="IE=' +
thisIsIE11() ? "edge" : "6" +
'">'
);
}
</script>
Of course, you can't do that in XHTML.
Alternately, detect server-side and vary what you send back.
And again, really, if you can possibly avoid doing this (and you almost certainly can)...

Update IE Doc Mode to latest version using script/ Tag

I have a requirement to update IE mode to latest version. How to know the latest version of IE using script?
I can use META tag but in meta tag we need to mention the browser version. If i mention the browser version as IE9, what if the end user user browser version is IE8?
<meta http-equiv="X-UA-Compatible" content="IE=9" />
I want to know the end user browser version and set the doc mode (If the user browser version is IE8/IE9, set doc mode as IE8/IE9)
how to achieve this?
Thanks in advance :)
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
The value edge means "using as recent a version as possible".

Print japanese with jQuery

I'm trying to print some Japanese to a page dynamically using jQuery, and it display nothing recognizable. I don't know what went wrong, I reduced the code to the most straight-forward, and it doesn't fix it. Or maybe it's just me being thick.
I use:
$('body').append('<p>日本語</p>');
Which should work, right?
And I get:
日本語
Huh?
Have you made sure that your page is set to use the Japanese character set? If not, make sure that your charset is defined in your <head></head> node :
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
In some cases Utf-8 character set would be helpful. Add this in your Head node as below.
<head>
<meta charset="utf-8" />
</head>

JQuery behaves strange with different IE8 security settings

Good day!
I'm not sure if I hit the bug, so please confirm that I'm not mad. I use IE 8.0.7600.16385 on 3 different machines.
Here is simple page (I tested with both JQuery 1.4.2 and 1.3.2). It just displays alert if hidden link is visible. It displays 'false' in all browsers I have and in my IE8 when security zone is set to 'Trusted intranet' or it in IE7 compatibility mode. But when I upload this page (or change security zone to 'Internet') -- it displays 'true'.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">
<head>
<title>
</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
$('#vct-save-settings').click(function(){
alert('Is visible hidden element: ' + $('#vct-show-similar').is(':visible'));
});
});
</script>
<div class="vct-controls">
Shown element
Hidden element
click me!
</div>
</body>
</html>
So, the question is: why JQuery behaves different regardless of IE8 security zones?
Thanks in advance!
Already logged in the jQuery bug tracker (bug 6199).
edit — also it just occurred to me that this might be a security thing related to the trick of putting a <a> tag on a page and having a ":visited" style for it, and then checking its current style via Javascript. That way, a page can tell what other sites you have visited. I don't know why this behavior in particular should result, but that's the only reason I can imagine that the security zone would figure into the behavior.

Categories

Resources