[js] ubb werkt niet
robmoorman - 18/01/2006 15:53
PHP interesse
kzit met probleempje... ik krijg niet voor elkaar dat hij ubb in mijn veldje zet, kzie de fout niet, hij geeft btw ook gene fout aan...
http://www.ener...&id=11
<img src="gfx/ubb/b.gif" border="0" alt="Bold" onClick="ubb('[b]', '[/b]', 'comment');" />
<img src="gfx/country/nl.gif" border="0" alt="" onClick="ubb('[flag=nl', ']', 'comment');" />
< img src= "gfx/ubb/b.gif" border= "0" alt= "Bold" onClick= "ubb('[b]', '[/b]', 'comment');" />
< img src= "gfx/country/nl.gif" border= "0" alt= "" onClick= "ubb('[flag=nl', ']', 'comment');" />
function ubb(opentag, closetag, elementid)
{
//IE SUPPORT
if (document.selection)
{
document.getElementById(elementid).focus();
sel = document.selection.createRange();
sel.text = opentag + sel.text + closetag;
}
//MOZILLA/NETSCAPE SUPPORT
else if (document.getElementById(elementid).selectionStart || document.getElementById(elementid).selectionStart == "0")
{
var selLength = document.getElementById(elementid).textLength;
var selStart = document.getElementById(elementid).selectionStart;
var selEnd = document.getElementById(elementid).selectionEnd;
if (selEnd==1 || selEnd==2) selEnd=selLength;
var s1 = (document.getElementById(elementid).value).substring(0,selStart);
var s2 = (document.getElementById(elementid).value).substring(selStart, selEnd)
var s3 = (document.getElementById(elementid).value).substring(selEnd, selLength);
document.getElementById(elementid).value = s1 + opentag + s2 + closetag + s3;
document.getElementById(elementid).focus();
}
}
function ubb( opentag, closetag, elementid)
{
//IE SUPPORT
if ( document. selection)
{
document. getElementById( elementid) . focus( ) ;
sel = document. selection. createRange( ) ;
sel. text = opentag + sel. text + closetag;
}
//MOZILLA/NETSCAPE SUPPORT
else if ( document. getElementById( elementid) . selectionStart || document. getElementById( elementid) . selectionStart == "0" )
{
var selLength = document. getElementById( elementid) . textLength;
var selStart = document. getElementById( elementid) . selectionStart;
var selEnd = document. getElementById( elementid) . selectionEnd;
if ( selEnd== 1 || selEnd== 2 ) selEnd= selLength;
var s1 = ( document. getElementById( elementid) . value) . substring( 0 , selStart) ;
var s2 = ( document. getElementById( elementid) . value) . substring( selStart, selEnd)
var s3 = ( document. getElementById( elementid) . value) . substring( selEnd, selLength) ;
document. getElementById( elementid) . value = s1 + opentag + s2 + closetag + s3;
document. getElementById( elementid) . focus( ) ;
}
}
iemand een idee ???
bvd rob
5 antwoorden
Gesponsorde links
Thomas - 18/01/2006 16:08
Moderator
Error: ubb is not defined
Weet je zeker dat je je UBB-functie ook ergens "include"?
robmoorman - 18/01/2006 16:12
PHP interesse
<script type="javascript" src="tpl/functions.js"></script>
jah, werk met .tpl's staat er gewoon in hoor....
BigBug - 18/01/2006 16:51
PHP expert
<html>
<head>
<title></title>
<script>
function addtext(veld, ubb) {
document.forms[0].elements[veld].value += ubb;
}
</script>
</head>
<body>
<form name='blaat' method='post'>
<textarea name="naam" cols="50" rows="10" id="S1"></textarea>
</form>
<img border="0" src="ubb/shiny.png" onClick="javascript:addtext('S1',':D')" width="15" height="15">
<img border="0" src="ubb/confused.png" onClick="javascript:addtext('S1',':s')">
<img border="0" src="ubb/coool.png" onClick="javascript:addtext('S1','(h)')">
<img border="0" src="ubb/cry.png" onClick="javascript:addtext('S1',':(')">
<img border="0" src="ubb/nosmile2.png" onClick="javascript:addtext('S1',':|')">
<img border="0" src="ubb/smile.png" onClick="javascript:addtext('S1',':)')">
<img border="0" src="ubb/wink.png" onClick="javascript:addtext('S1',';)')">
<img border="0" src="ubb/yummie.png" onClick="javascript:addtext('S1',':lekker:')">
<img border="0" src="ubb/shutup.png" onClick="javascript:addtext('S1',':x')">
<img border="0" src="ubb/sleephappy.png" onClick="javascript:addtext('S1','zZzZz')">
<img border="0" src="ubb/kwijl.png" onClick="javascript:addtext('S1',':kwijl:')">
<img border="0" src="ubb/nerd.png" onClick="javascript:addtext('S1',':nerd:')">
<img border="0" src="ubb/heart.png" onClick="javascript:addtext('S1','(l)')">
<img border="0" src="ubb/clown.png" onClick="javascript:addtext('S1',':clown:')"><img border="0" src="ubb/bonk.png" onClick="javascript:addtext('S1','8-|')">
<?php
function ubb()
{
str_replace($Opgehaald['bericht'],":D","<img src='shiny.png'>");
}
?>
</body>
</html>
<html>
<head>
<title></title>
<script>
function addtext(veld, ubb) {
document.forms[0].elements[veld].value += ubb;
}
</script>
</head>
<body>
<form name='blaat' method='post'>
<textarea name="naam" cols="50" rows="10" id="S1"></textarea>
</form>
<img border="0" src="ubb/shiny.png" onClick="javascript:addtext('S1',':D')" width="15" height="15">
<img border="0" src="ubb/confused.png" onClick="javascript:addtext('S1',':s')">
<img border="0" src="ubb/coool.png" onClick="javascript:addtext('S1','(h)')">
<img border="0" src="ubb/cry.png" onClick="javascript:addtext('S1',':(')">
<img border="0" src="ubb/nosmile2.png" onClick="javascript:addtext('S1',':|')">
<img border="0" src="ubb/smile.png" onClick="javascript:addtext('S1',':)')">
<img border="0" src="ubb/wink.png" onClick="javascript:addtext('S1',';)')">
<img border="0" src="ubb/yummie.png" onClick="javascript:addtext('S1',':lekker:')">
<img border="0" src="ubb/shutup.png" onClick="javascript:addtext('S1',':x')">
<img border="0" src="ubb/sleephappy.png" onClick="javascript:addtext('S1','zZzZz')">
<img border="0" src="ubb/kwijl.png" onClick="javascript:addtext('S1',':kwijl:')">
<img border="0" src="ubb/nerd.png" onClick="javascript:addtext('S1',':nerd:')">
<img border="0" src="ubb/heart.png" onClick="javascript:addtext('S1','(l)')">
<img border="0" src="ubb/clown.png" onClick="javascript:addtext('S1',':clown:')"><img border="0" src="ubb/bonk.png" onClick="javascript:addtext('S1','8-|')">
<?php
function ubb( )
{
str_replace ( $Opgehaald [ 'bericht' ] , ":D" , "<img src='shiny.png'>" ) ; }
?>
</body>
</html>
Ik gebruik deze, werkt perfect in IE en FF..
Offtopic... Zwolle? Ga daar naar school
Gesponsorde links
Dit onderwerp is gesloten .