PHP在线编辑器 只要一个功能 添加表情

来源:百度知道 编辑:UC知道 时间:2024/06/30 09:25:48
只要一个功能 添加表情

就像人人网的留言一样 只要一个功能

多的不要

<?php
function get_ubb($str) {

$str = preg_replace("/(\[)em(.*?)(\])/i", "<img src=\"em/\\2.gif\" />", $str);
return $str;
}

if($_POST['sub']){
echo get_ubb($_POST[message]);
}

?>
<script>
function inserttag(topen,tclose){
var themess = document.getElementById('con');//编辑对象
themess.focus();
if (document.selection) {//如果是否ie浏览器
var theSelection = document.selection.createRange().text;//获取选区文字
//alert(theSelection);
if(theSelection){
document.selection.createRange().text = theSelection = topen+theSelection+tclose;//替换
}else{
document.selection.createRange().text = topen+tclose;
}
theSelection='';

}else{//其他浏览器

var scrollPos = themess.scrollTop;
var selLength = themess.textLength;
var selStart = th