Lid |
|
ik gebruik volgende code om ubb tags te plaatsen in een textarea, dit script werkt perfect in Safari en Firefox, maar in ie6 zet hij de tags niet rond de selectie... Hoe komt dit en is dit oplosbaar? weet niet hoe het in ie7 werkt, want heb geen goesting om mijn vista dualboot op te starten voor 5 minuten te kijken...
function ubb(tag1, tag2) {
var field = document.frmPost.bericht;
if (field.setSelectionRange) {
if (tag2 == undefined) {
field.value = field.value.substring(0,field.selectionStart)
+ "["+ tag1 +"]"
+ field.value.substring(field.selectionStart,field.selectionEnd)
+ "[/"+ tag1 +"]"
+ field.value.substring(field.selectionEnd,field.value.length);
field.focus();
} else {
field.value = field.value.substring(0,field.selectionStart)
+ "["+ tag1 +"="+ tag2 +"]"
+ field.value.substring(field.selectionStart,field.selectionEnd)
+ "[/"+ tag1 +"]"
+ field.value.substring(field.selectionEnd,field.value.length);
field.focus();
}
} else if (document.selection && document.selection.createRange) {
field.focus();
var range = document.selection.createRange();
if (tag2 == undefined) {
range.text ="["+ tag1 +"]" + range.text + "[/"+ tag1 +"]";
} else {
range.text ="["+ tag1 +"="+ tag2 +"]" + range.text + "[/"+ tag1 +"]";
}
}
}
function ubb(tag1, tag2) { var field = document.frmPost.bericht; if (field.setSelectionRange) { if (tag2 == undefined) { field.value = field.value.substring(0,field.selectionStart) + "["+ tag1 +"]" + field.value.substring(field.selectionStart,field.selectionEnd) + "[/"+ tag1 +"]" + field.value.substring(field.selectionEnd,field.value.length); field.focus(); } else { field.value = field.value.substring(0,field.selectionStart) + "["+ tag1 +"="+ tag2 +"]" + field.value.substring(field.selectionStart,field.selectionEnd) + "[/"+ tag1 +"]" + field.value.substring(field.selectionEnd,field.value.length); field.focus(); } } else if (document.selection && document.selection.createRange) { field.focus(); var range = document.selection.createRange(); if (tag2 == undefined) { range.text ="["+ tag1 +"]" + range.text + "[/"+ tag1 +"]"; } else { range.text ="["+ tag1 +"="+ tag2 +"]" + range.text + "[/"+ tag1 +"]"; } } }
edit: weet nu echt niemand het antwoord?
|