Archive for the ‘ SEO ’ Category

innerHTML removes attribute quotes in Internet Explorer

After losing 2 hours for an unknown XML parsing error, I have discovered that the results of innerHTML in Internet Explorer are wrong.

1
2
3
4
5
6
7
8
// Original Source code of document
<div id="container">container</div>
// Result of innerHTML in document.getElementById('content')

//Firefox
<div id="container">container</div>
//Internet Explorer
<DIV id=container>container</DIV>

The solution: innerXHTML

1
2
var container = document.getElementById('container');
var code = innerXHTML(container);

Download innerxhtml