0

Is there a way to show on a web page which browser mode and which document mode is set?

Is this generally possible and is it possible to show/hide some content depending of which mode is switched on?

I would like to use a function to allow upload by drag and drop (see http://blueimp.github.com/jQuery-File-Upload/) but I noticed that this works only when IE is in a specific Document Mode. In case this mode is not switched on I would like to disable the Option to upload by drag and drop.

il_guru
  • 8,383
  • 2
  • 42
  • 51
NilsB
  • 1,154
  • 1
  • 16
  • 42

3 Answers3

1
var j = jQuery.noConflict();
j(document).ready(function(){
    /* detect usage of IE Developer Tools using different Mode for Browser and Document */
    if(j.browser.msie) {
        var browserVersion = j.browser.version.slice(0,j.browser.version.indexOf("."));
        var documentVersion = document.documentMode;
        if(browserVersion != documentVersion) {
            alert("ERROR:\nBrowser Mode and Document Mode do not match!\n\nBrowser Mode: IE"+ browserVersion +".0\nDocument Mode: IE"+ documentVersion +".0");
        }
    }
});

Courtesy: http://my.opera.com/Schalandra/blog/2012/02/29/how-to-detect-different-browser-mode-and-document-mode-in-ie

Maybe you'll find this answer helpful too.

https://stackoverflow.com/a/623071/903454

Community
  • 1
  • 1
5hahiL
  • 1,056
  • 16
  • 36
1

You can detect the document-mode:

var mode = document.documentMode;

If the mode is Internet Exlporer 5, it returns five, if it's IE6, it returns 6, and so on.

However, you can force a specific document mode:

<meta http-equiv="X-UA-Compatible" content="IE=[IEVersion]">

Where [IEVersion] is one of the following:

  • Edge Always the newest version
  • EmulateIE9 If the doctype is set, the mode is IE9, otherwise IE5
  • EmulateIE8 See EmulateIE9
  • EmulateIE7 See EmulateIE9
  • 9 Alway IE9
  • 8 Always IE8
  • 7 Always IE7
  • 5 Always IE5

PS: Your plugin should recognize the mode automatically.

looper
  • 1,929
  • 23
  • 42
0

You can use document.documentMode in IE to find out html document

  • 5 The page is displayed in IE5 mode
  • 7 The page is displayed in IE7mode
  • 8 The page is displayed in IE8 mode
  • 9 The page is displayed in IE9 mode
Murali N
  • 3,451
  • 4
  • 27
  • 38