UBB-Style tags with IE and Mozilla

J

Jörg Dembski

Hey,

i got a code-snippet to insert around a selected text
in a textarea html-form inputfield.
This code works fine with IE, but with Opera / Mozilla / Konqueror
just nothing happens.

Here is the code snippet:

var seltext = null;
var repltext = null;
function InsertTag(strOpen,strClose)
{
seltext = (document.all)?
document.selection.createRange() : document.getSelection();
var selit = (document.all)?
document.selection.createRange().text : document.getSelection();
if (selit.length>=1)
{
if (seltext)
{
repltext= strOpen + selit + strClose;
if ((repltext=='')||(repltext==null)) repltext=seltext.text;
seltext.text = repltext;
window.focus()
}
}
else
{
alert(document.frmTest.strHTML.caretPos)
}
}


And then in the html-form:
<input type="button" value="B" onclick="javascript:InsertTag('', '');">


As i said, IE works fine. Mozilla won't :(


Thx for any help in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top