document.body.innerHTML fails on IE when setting it to "<P><HR>" - html

Our application uses embedded IE control, and we noticed that setting:
document.body.innerHTML it to <P><HR> causes an OLE exception "Unknown runtime error".
I could reproduce this in the IE browser itself (IE version 8).
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Untitled</title>
<script>
function load(){
// alert(document.body.innerHTML)
document.body.innerHTML = '<P><HR>';
}
</script>
</head>
<body onload="load()">
</body>
</html>
If the body.innerHTML is set to <P></P><HR> all is good. but the problem that the HTML strings are coming from a DB. Why is this happening and how can this be fixed?
EDIT: The code works fine on IE11. but the problem exists on systems with IE8. no matter if I change FEATURE_CONTROL_BROWSER_EMULATION key. Is there anything could be done for IE8?

The MSIE WBC (Web browser control), whether hosted by a Delphi or .net desktop application use IE7 Emulation by default.... To determine which IE emulation mode your hosted WBC is using add the following snippet to the onload event.
alert(document.documentMode?document.documentMode:'n/a');
To make your WBC use the IE emulation mode you need to add a registry entry in the FEATURE_CONTROL_BROWSER_EMULATION key in the registry.
see the documentation here - https://msdn.microsoft.com/en-us/library/ms537184%28v=vs.85%29.aspx
to get your invalid markup to work.
1. use a valid document type declaration. ().
2. change your FEATURE_CONTROL_BROWSER_EMULATION value in the registry to emulate IE8 or higher....
Ideally you want your WBC to emulate IE11 and modern web standards for html5, but that may not be possible if your existing markup is pre-HTML5,CSS 3.(viz: your markup was developed for IE6 on an intranet website, using DHTML (the early MS versions of HTML).

Related

DOCTYPE HTML not start my webpage on the localhost with console IE message

I´m tryng to run my webpage containing basics scripts <?php..?>,<script>...</script>, in LOCALHOST server, using Apache2triad.
It happens that script are running only to find <!DOCTYPE...> or without it in the IE console, the messages are sending like:
HTML1300:Navigation occured.
HTML1527: DOCTYPE expected. Consider adding a valid HTML5 doctype: "<!DOCTYPE html>".
I already try to use declaration, like:
<!DOCTYPE HTML>
<html>
<body>
<?php echo "Ok, running...."; ?>
or simply:
<html>
<body>
But the console error problem persist... Have you got some idea whats is happening with the server?
Thanks.
Your problem is IE compatibility (it has nothing to do with Apache):
How to use Compatibility View in Internet Explorer 9
You can try to add X-UA-Compatible meta tag:
(it also fixes some layout issues that occur in IE10):
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
A quote from Mozilla's Quirks Mode:
The DOCTYPE shown in the example, , is the simplest
possible, and the one recommended by HTML5. Earlier versions of the
HTML standard recommended other variants, but all existing browsers
today will use full standards mode for this DOCTYPE, even the dated
Internet Explorer 6. There are no valid reasons to use a more
complicated DOCTYPE. If you do use another DOCTYPE, you may risk
choosing one, which triggers almost standards mode or quirks mode.
How do you see which mode is used?
In Internet Explorer, press F12, and look for Document Mode.

Google Map not displaying at all in IE10

The current webpage isn't showing the gmap at all under IE10 but all the other browsers are able to display it properly. Can someone guide me through a possible solution?
I've tried the
META http-equiv=X-UA-Compatible content=IE=9
and
META http-equiv=X-UA-Compatible content=IE=edge
without success!
I'm currently using drupal 7 for the website and a gmap module.
Thanks for the replies
I have identify your error why it is giving this error it is because You have set this meta tag
<meta http-equiv="X-UA-Compatible" content="IE=8">
As per IE10 Browser Standard mode and Other Browser version IE8 Standard which is not support the Console's Following method
Console.log();
Console.info();
Console.warn();
But, If you can set the IE mode to 9 it will be work.
In IE10 Version there is 4 different methods are available in which Console.dir() is used instead of above 3.
In your Javascript file give this error:
"SCRIPT438: Object doesn't support property or method 'warn' Bmain,adsense,geometry,zombie.js, line 70 character 35".
In that case you cannot change the javascript because it is load from the Google CDN.
So, possible you can add the following to your HTML will help you to change the Document Standard Mode to IE=9.
<meta http-equiv="X-UA-Compatible" content="IE=8">
Reff: http://msdn.microsoft.com/en-us/library/ie/jj819729(v=vs.85).aspx

How do I programatically set the Browser Mode in Internet Explorer

IE has a Browser Mode and Document Mode and I can only seem to set the Document Mode programatically by adding this:
<meta http-equiv="X-UA-Compatible" content="IE=5" />
This sets Document Mode correctly for me, but I need the Browser Mode to change to Compatibility View. My site only works with these two settings this way. I've tried changing the DocType and other meta settings but nothing seems to work. I've also confirmed my IE settings under Tools->Compatibility Settings have all 3 check-boxes unchecked and nothing in the listbox.
My website is ASP.NET 2.0 running on IIS6 (Windows 2003 Server).
Here is a simple sample site that demonstrates this. Open this in IE10 and then look at the developer tools (F12):
<html>
<head>
<title>This is the title</title>
<meta http-equiv="X-UA-Compatible" content="IE=5" />
<script type="text/jscript" language="jscript">
function foo() {
alert("document.documentMode: " + document.documentMode +
"\n\rdocument.compatMode: " + document.compatMode +
"\n\rnavigator.userAgent: " + navigator.userAgent);
}
</script>
</head>
<body onload="javascript:foo();">
This is a test site
</body>
</html>
First, requisite chiding: if this is your site, you should fix it to work with modern standards.
That said, you're likely accessing this site in such a way that it is loaded in the Intranet Zone, and you said that you've disabled the option to display intranet sites in compatibility view in compatibility view settings. (I believe it is enabled by default.)
Intranet Zone settings override your page's settings, so you have to re-enable that option.

How to force IE10 to render page in IE9 document mode

I have two questions:
How can I force IE10 to render in IE9 document mode? Currently it's rendering my page in Standard document mode.
In IE10's developer toolbar, I am not able to see the option of document mode of IE10. Is it not implemented, or is my browser version is out of date?
Thanks for all your help.
Edit: thanks everyone for the solutions provided. Earlier I was using a meta tag
<meta http-equiv="x-ua-compatible" content="IE=edge" >
just to make sure that IE will render the page in highest document mode, but I was facing some issues with IE10 standard mode, so I changed the meta tag to render the page in IE9 mode:
<meta http-equiv="x-ua-compatible" content="IE=9" >.
You should be able to do it using the X-UA meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
However, if you find yourself having to do this, you're probably doing something wrong and should take a look at what you're doing and see if you can do it a different/better way.
Do you mean you want to tell your copy of IE 10 to render the pages it views in IE 9 mode?
Or do you mean you want your website to force IE 10 to render it in IE 9 mode?
For the former:
To force a webpage you are viewing in Internet Explorer 10 into a particular document compatibility mode, first open F12 Tools by pressing the F12 key. Then, on the Browser Mode menu, click Internet Explorer 10, and on the Document Mode menu, click Standards.
http://msdn.microsoft.com/en-gb/library/ie/hh920756(v=vs.85).aspx
For the latter, the other answers are correct, but I wouldn't advise doing that. IE 10 is more standards-compliant (i.e. more similar to other browsers) than IE 9.
You can tweak the Registry if you want to make changes only to your own system. If you have IE10 and lots of web sites you visit don't render properly in IE10, then you can tweak your registry to force IE to open in IE9 mode.
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
Create a DWORD as iexplore.exe and give value 9999. Restart your IE and it will open in IE9 mode :)
Thanks to my colleague Sreejith D :)
I haven't seen this done before, but this is how it was done for emulating IE 8/7 when using IE 9:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
If not, then try this one:
<meta http-equiv="X-UA-Compatible" content="IE=9">
Add those to your header with the other meta tags. This should force IE10 to render as IE9.
Another option you could do (assuming you are using PHP) is add this to your .htaccess file:
Header set X-UA-Compatible "IE=9"
This will perform the action universally, rather than having to worry about adding the meta tag to all of your headers.
By what this says, IE10 (the article is referred to a preview release, anyway) it's able to use X-UA-Compatible only if the document is in quirks mode (no DOCTYPE), otherwise IE10 won't react to the request.
Here's an excerpt:
Thus, to make IE10 react to the X-UA-Compatible directive, one must either create a page that triggers quirks-mode per the rules of HTML5 (that is: an a page with no doctype). One can also send the directive as a HTTP header, however: A HTTP sent directive appears to have no effect if you use it to downgrade the rendering — it can only be used to upgrade the rendering
So, you've to do it manually with Dvelopers Tools, or with quirks mode (but I suggest to stay in IE10 mode which is for the first time aligned to the other browers' standard)
EDIT: The follows are some useful link to read:
http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx
http://blogs.msdn.com/b/ie/archive/2011/12/14/interoperable-html5-quirks-mode-in-ie10.aspx
You can force IE10 to render in IE9 mode by adding:
<meta http-equiv="X-UA-Compatible" content="IE=9">
in your <head> tag.
See MSDN for more information...
there are many ways can do this:
add X-UA-Compatible
tag to head
http response header
using IE tools F12
change windows Registry
The hack is recursive. It is like IE itself uses the component that is used by many other processes which want "web component". Hence in registry we add IEXPLORE.exe. In effect it is a recursive hack.
I found this post while I was looking for a solution to my DNN6 website.
The error was
SCRIPT5007: Unable to get property 'documentElement' of undefined or
null reference
But I needed the same solution: force compability mode to IE9. So let me share with you what I did to solve this.
So, for DotNetNuke 6 users try the StyleHelper SkinObject
Worked great for me!

Compatibility issue in IE8 - ASP.NET MVC 3.0 intra application

We have been developing ASP.NET MVC 3.0(Razor & HTML 5) application with IIS 7.5. The site should run on IE8.
The site content displays properly when the comaptibility mode is OFF. But, if it runs with compatibility mode on then the few elements goes outside horizontally.
As the company's IE policy, all the intranet application runs under the "Compatibility Mode" hence I can't change that part.
What should be possible solution?
1. Is there any way when the application url gets renedered, I explicitly instruct browser to not run under compatibility mode (programmatically)?
2. Is there any ways in IIS 7.5 to enforce rendering targeting IE 8.0+?
3. Do I need to target to HTML 4.0 and convert all the fuzzy css/html targeting older html version?
I am seriously out of idea. It may possible the above direction points are also logic-less.
Please suggest somthing on this.
You'll need to set the X-UA-Compatible header. You can do in at least two ways:
Add the following to every page:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
Or you can tell IIS to send it with every response following these instructions to set custom headers to every response.
For a list of values you can use X-UA-Compatible look at this page.
Add this <meta> tag inside <head>:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
This should force IE to use the most up-to-date rendering engine available.