
23.04.2007, 06:43
|
|
♠ ♦ ♣ ♥
Регистрация: 18.05.2006
Сообщений: 1,828
Провел на форуме: 8042357
Репутация:
3742
|
|
Код:
function smilie(thesmilie)
{
getActiveText();
var AddSmilie = " " + thesmilie + " ";
AddText(AddSmilie);
}
function AddText(NewCode)
{
if (typeof(theform.message.createTextRange) != "undefined" && theform.message.caretPos)
{
var caretPos = theform.message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
caretPos.select();
}
else if (theform.message.selectionStart || theform.message.selectionStart == '0')
{ // its mozilla and we'll need to re-write entire text
var start_selection = theform.message.selectionStart;
var end_selection = theform.message.selectionEnd;
// fetch everything from start of text area to selection start
var start = (theform.message.value).substring(0, start_selection);
// fetch everything from start of selection to end of selection
var middle = NewCode;
// fetch everything from end of selection to end of text area
var end = (theform.message.value).substring(end_selection, theform.message.textLength);
theform.message.value = start + middle + end;
setfocus();
theform.message.selectionStart = end_selection + middle.length;
theform.message.selectionEnd = start_selection + middle.length;
getActiveText();
AddTxt = "";
return;
}
else
{
theform.message.value += NewCode;
}
setfocus();
getActiveText();
AddTxt = "";
}
<a href="#" onclick="smilie(';)'); return false;"><img src="images/smilies/smilehz.gif" alt="Wink" border="0" /></a>
и тд
наркоманское решение .. но все же =)
__________________
Привет! Меня зовут Джордж, и я хотел бы рассказать вам про реинкарнацию (ц) 2x2
Последний раз редактировалось blackybr; 23.04.2007 в 06:57..
|
|
|