Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeMirror in .Net WebBrowser #1149

Closed
lrocher opened this issue Jan 10, 2013 · 2 comments
Closed

CodeMirror in .Net WebBrowser #1149

lrocher opened this issue Jan 10, 2013 · 2 comments

Comments

@lrocher
Copy link

lrocher commented Jan 10, 2013

Hi,

For a project, i integrate CodeMirror 3.0 in a System.Windows.Controls.WebBrowser (.Net component).
I have display issue when scrolling horizontally (scrolled text part overlap gutter).
This problem not occur when i run same html code in my desktop IE navigator

.Net Browser look to work in IE7 rendering mode by default even if i have IE8 installed.
I have add a meta tag with: http-equiv="X-UA-Compatible" content="IE=edge"
Engine is correctly turn to IE8 rendering but CodeMirror didn't detect it (detect as ie7).

Problem is link to IE version detection in codemirror. It's based on navigator.userAgent.
but WebBrowser component continue to give same userAgent (MSIE7) even if IE8 rendering is enabled.

In codemirror.js, If i replace :

var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent);
var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);

with:

var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt8 = ie && (typeof(document.documentMode) === "undefined" ? true : document.documentMode < 8);
var ie_lt9 = ie && (typeof(document.documentMode) === "undefined" ? true : document.documentMode < 9);

It's work correctly.

Note : document.documentMode property is defined since IE8 only.
http://msdn.microsoft.com/en-us/library/cc196988%28v=VS.85%29.aspx

@0b10011
Copy link
Contributor

0b10011 commented Jan 10, 2013

A few [possible] gotchas with the provided code

Quirks mode returns 5 (but this probably isn't an issue since quirks mode isn't supported):

Variant of type Floating-point that receives one of the following values.
5 - Internet Explorer 5 mode (also known as "quirks mode").

document.documentMode can return 0 instead of the actual documentMode:

When the current document has not yet been determined, documentMode returns a value of zero (0). This usually happens when a document is loading. When a return value of zero is received, try to determine the document compatibility mode at a later time.

Will document.documentMode return when not in compatibility mode (normal browsing)? Probably, but worth checking.

This property is available in all compatibility modes.

@marijnh
Copy link
Member

marijnh commented Jan 14, 2013

I've integrated your suggestion. document.documentMode seems to be available and initialized even when running code at the top of the <head> tag.

You'll still not get a very good experience running CodeMirror in IE7 mode, I expect. Might want to consider using release 2.37 instead of 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants