wrapSelection is geen standaard functie :)
Link gekopieerd
Oh, oeps. Kreeg nog al veel hits met google => iets te snel geconcludeerd... :-( Jammer
Link gekopieerd
Heb nu dit, maar wil ook niet echt lukken.
<script type="text/javascript">
function wrapSelection (input, preString, postString)
{
if (input.setSelectionRange) {
var selectionStart = input.selectionStart;
var selectionEnd = input.selectionEnd;
input.value = input.value.substring(0, selectionStart)
+ preString
+ input.value.substring(selectionStart,selectionEnd)
+ postString
+ input.value.substring(selectionEnd);
if (selectionStart != selectionEnd) // has there been a selection
setSelectionRange(input, selectionStart, preString.length + postString.length + selectionEnd);
else // set caret
setCaretToPos(input, selectionStart + (preString+postString).length);
} else if (document.selection) {
var sel = document.selection.createRange().text;
if(sel) {
document.selection.createRange().text = preString + sel + postString;
input.focus();
} else {
input.value += preString + postString;
input.focus();
}
} else {
input.value += preString + postString;
// input.focus();
}
}
function ubb(type,veld)
{
if (type == 'url')
{
wrapSelection(veld,'[url]','[/url]');
}
if (type == 'quote')
{
}
if (type == 'b')
{
}
if (type == 'i')
{
}
if (type == 's')
{
}
if (type == 'img')
{
}
if (type == 'u')
{
}
if (type == 'size')
{
}
if (type == 'color')
{
}
}
</script>
<a onclick="ubb('url','reactie');">URL</a><br />
<a onclick="ubb('quote','reactie');">Quote</a><br />
<a onclick="ubb('b','reactie');">B</a><br />
<a onclick="ubb('u','reactie');">U</a><br />
<a onclick="ubb('i','reactie');">I</a><br />
<a onclick="ubb('s','reactie');">S</a><br />
<a onclick="ubb('color','reactie');">Color</a><br />
<a onclick="ubb('size','reactie');">Size</a><br />
<a onclick="ubb('img','reactie');">img</a><br />
<textarea cols="50" rows="50" id="reactie"></textarea>
Error:
input.focus is not a function
ae.php (line 28)
wrapSelectionae.php (line 28)
ubbae.php (line 37)
onclickae.php (line 1)
Voorbeeld:
klik
Link gekopieerd
ik krijg geen error? ik krijg wat tekst met url img enzo en een tekstvak
Link gekopieerd
Ja, en als je op "URL" klikt, dan krijg je een javascript error.
Link gekopieerd