0
var dossierTable= document.getElementById('DossierTable');
var newRow = dossierTable.insertRow(currentRowIndex + 1);
var newTable = '<td colspan=\'11\'>';
newTable += '<div id=\'' + divId + '\'><img src=\'./img.gif\'/></div</td>';
newRow.innerHTML = newTable;

I have an issue in IE with this code snippets above due to innerHTML. This works perfectly with Chrome and Firefox but not with IE. But with IE if I run Developer Tools F12 and I change the document version to 11 it works as long the developer tools is open. When it's closed the issue appears again.

Someone have and idea about how to solve this issue. Thank in advance.

zzzzBov
  • 157,699
  • 47
  • 307
  • 349
KJulian
  • 1
  • 2
  • 1
    Sounds like IE is reverting to an older document mode. You can place a meta tag in the head of your page to tell IE to use IE11 document mode, here is an SO post which shows how to do this (https://stackoverflow.com/questions/22034924/how-to-set-ie11-document-mode-to-edge-as-default) – Ryan Wilson Jun 01 '18 at 17:59
  • Did you happen to use any `console.log` statements in your actual code? That would explain why the code only works when the console is open as `console.log` would otherwise produce a `ReferenceError` – zzzzBov Jun 01 '18 at 18:00
  • 1
    IE is likely working in "intranet mode", if the server you're hitting is localhost or something without a TLD. That causes it to revert to earlier quirks. Add a `` to the head of your document, or add the HTTP header to the response from the server. See [Override intranet compatibility mode IE8](https://stackoverflow.com/q/2518256) – Heretic Monkey Jun 01 '18 at 18:02
  • @MikeMcCaughan Great minds think alike! :P – Ryan Wilson Jun 01 '18 at 18:03
  • @RyanWilson Ha! I didn't see your comment mentioned that meta tag. – Heretic Monkey Jun 01 '18 at 18:04

1 Answers1

0

Thank you all for yours answers. As said by Mike McCaughan the issue was related by the head of the document, <meta http-equiv="X-UA-Compatible" content="IE=edge"> was set on the wrong placed (after script declaration). Moved it before those script that solved my issue.

Heretic Monkey
  • 10,498
  • 6
  • 45
  • 102
KJulian
  • 1
  • 2