Javascript function that returns a DOM when input is html content
<p>I want a Javascript function that returns a correct DOM when input is HTML content.
I have used the follwing function for the same. Here input is HTML content and output is DOM.</p>

<pre><code>function htmltoelement(elementHTML)
{   
    var temDiv = document.createElement('div');
    temDiv.innerHTML = elementHTML;        
    return temDiv;
}
</code></pre>

<p>This function works well for Firefox, but not for IE or Chrome, when the HTML is broken.</p>

<p>I need a suggestion for a function that works fine on all the browsers even when HTML is broken. </p>
