Javascript Selected Formatting not working in browser while in dreamweaver it does
<p>I'm having some trouble with this script. It is suposed to add html tags to a selected text region in a text box.
While live viewing in dreamweaver it works just fine. Exactly how it's suposed to. In browser it does nothing.</p>

<p>Any thoughts?</p>

<p>The function is called with <code>onclick="formatText(content,'b')"</code>.</p>

<pre><code>function formatText(el, tag) {
    var selectedText = document.selection ? document.selection.createRange().text
            : el.value.substring(el.selectionStart, el.selectionEnd);
    alert(selectedText);
    if (selectedText != '') {
        var newText = '&lt;' + tag + '&gt;' + selectedText + '&lt;/' + tag + '&gt;';
        el.value = el.value.replace(selectedText, newText);
        document.getElementById(el).focus();
    } else {
        if (document.getElementById(tag).value == "0") {
            document.getElementById(tag).value = "1";
            document.getElementById(el).value = document.getElementById(el).value
                    + "&lt;" + tag + "&gt;";
            document.getElementById(el).focus();
        } else {
            document.getElementById(tag).value = "0";
            document.getElementById(el).value = document.getElementById(el).value
                    + "&lt;/" + tag + "&gt;";
            document.getElementById(el).focus();
        }
    }
}
</code></pre>
