Hallo,
habe folgendes Script zum ersetzen von BBCode, leider kennt der MAC Safari weder:
document.selection
noch
document.forms[form].elements[field].selectionStart
Weiß jemand Rat???
habe folgendes Script zum ersetzen von BBCode, leider kennt der MAC Safari weder:
document.selection
noch
document.forms[form].elements[field].selectionStart
PHP-Code:
function bbcode(form,field,v)
{
if (!document.forms[form].elements[field].selectionStart){
alert("safari");
}
if (!document.selection){
alert("safari");
}// for IE
if (document.selection)
{
var str = document.selection.createRange().text;
document.forms[form].elements[field].focus();
var sel = document.selection.createRange();
sel.text = "[" + v + "]" + str + "[/" + v + "]";
return;
}// for Mozilla
else if ((typeof document.forms[form].elements[field].selectionStart) != 'undefined')
{
var txtarea = document.forms[form].elements[field];
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var oldScrollTop = txtarea.scrollTop;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + '[' + v + ']' + s2 + '[/' + v + ']' + s3;
txtarea.selectionStart = s1.length;
txtarea.selectionEnd = s1.length + 5 + s2.length + v.length * 2;
txtarea.scrollTop = oldScrollTop;
txtarea.focus();
return;
}
else insert(form,field,'[' + v + '][/' + v + '] ');
}
Kommentar