|
|
|
|
function addBBCode(element, tag) {
var element = document.getElementById(element);
var startTag = '['+tag+']';
var endTag = '[/'+tag+']';
if (typeof element.selectionStart != 'undefined') {
// add bb code around the selection
var bbCodeText = startTag + element.value.substring(element.selectionStart, element.selectionEnd) + endTag;
element.value = element.value.substr(0, element.selectionStart) + bbCodeText + element.value.substr(element.selectionEnd);
// set cursor
posNew = element.selectionStart + bbCodeText.length;
element.selectionStart = posNew;
element.selectionEnd = posNew;
} else if (typeof document.selection != 'undefined') {
element.focus();
var range = document.selection.createRange();
range.text = startTag + range.text + endTag;
range.select();
} else {
element.value += startTag + endTag;
}
// set the focus back to the element
element.focus();
}
|
что сделать что бы в IE6 работал коректно? также как и в Opera... | |
|
|