how to make this texarea javascript work in other browsers except Internet Explorer
<p>Please can someone help me out on this</p>

<p>this is a JavaScript code that inserts a particular bbcode say [b] [/b] in a textarea box when the user clicks on it like it is in V Bulletin and SMF forums, when the user clicks on an image with <strong>B</strong> [b][/b] appears in the textarea form,</p>

<p>now i made mine to work though am not good in JavaScript
but the problem is that it only works in <strong>INTERNET EXPLORER</strong> and doesn't work in OPERA and Mozilla 
so I need help to make it work in other browser apart from IE</p>

<pre><code>&lt;HTML&gt;
 &lt;Head&gt;
 &lt;script type="text/javascript"&gt;

 var isSelected = false;

 function copySelection(workArea){

 workArea.workText = document.selection.createRange();
 isSelected = true;
 }

 function wrapInTags(workArea,isTag){

 if (isSelected)
 {
 workArea.workText.text = "["+isTag+"]"+workArea.workText.text+"[/"+isTag+"]";
 if (workArea.workText.text==''){isSelected=false;workArea.focus()}
 }
 }

 function AddURL(workArea){

 var AddURL="";
 var txt="";


 txt=prompt("Enter URL for the link.","http://");
 AddURL="[.url="+txt+"]";
 AddURL2="[./url]";


 if (isSelected)
 {
 workArea.workText.text = AddURL+workArea.workText.text+AddURL2;
 if (workArea.workText.text==''){isSelected=false;workArea.focus()}
 }

 }

 &lt;/Script&gt;
 &lt;/Head&gt;


 &lt;Body&gt;
 &lt;Form name='Form1' method=post action='process.php'&gt;
 &lt;textarea name='area1' cols='40' rows='4' onselect="copySelection(this)"&gt;&lt;/textarea&gt;&lt;br&gt;
 &lt;input type=button value='Italic' onclick="wrapInTags(this.form.area1,'i')"&gt;
 &lt;input type=button value='Bold' onclick="wrapInTags(this.form.area1,'b')"&gt;
 &lt;input type=button value='Underline' onclick="wrapInTags(this.form.area1,'u')"&gt;
 &lt;input type=button value='Link' onclick="AddURL(this.form.area1)"&gt;
 &lt;br&gt;&lt;br&gt;
 &lt;input type=submit value='Submit'&gt;
 &lt;/Form&gt;


 &lt;/Body&gt;
 &lt;/HTML&gt;
</code></pre>
