Need a small improvement in this function
<p>I found a great script in one of the posts. That is working like a charm in Mozilla and Chrome but in IE it is working partially(Only text without HTML tags in original html are matching...) Here i am attaching an image to show the same.. <img src="http://i.stack.imgur.com/4KCcS.jpg" alt="Here is the image">.<br>
I want to search for a string in a window and highligh it if found by considering the text in textbox as input.
The script and fiddle i found are  </p>

<pre><code>function doSearch(text) {
 if (window.find &amp;&amp; window.getSelection) {
    document.designMode = "on";
    var sel = window.getSelection();
    sel.collapse(document.body, 0);

    while (window.find(text)) {
        document.getElementById("button").blur();
        document.execCommand("HiliteColor", false, "yellow");
        sel.collapseToEnd();
    }
    document.designMode = "off";
} else if (document.body.createTextRange) {
    var textRange = document.body.createTextRange();
    while (textRange.findText(text)) {
        textRange.execCommand("BackColor", false, "yellow");
        textRange.collapse(false);
    }
}
</code></pre>

<p>}</p>

<p>and fiddle is <a href="http://jsfiddle.net/xeSQb/6/" rel="nofollow">here</a><br>
I am not that much sound in knowledge to edit this script. Please someone help me to work in IE also...</p>
