J
Jörg Dembski
Betreff: UBB-Style tags with IE and Mozilla
Von: Jörg Dembski <[email protected]>
Gruppen: comp.lang.javascript
Datum: Thu, 08 Jul 2004 17:49:29 +0200
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
Von: Jörg Dembski <[email protected]>
Gruppen: comp.lang.javascript
Datum: Thu, 08 Jul 2004 17:49:29 +0200
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