user-pic

在评论框中添加表情图标按键

Vote 1 Vote

1、在要单页面中添加JS代码:

<script type="text/javascript" language="javascript">

<!--
function emoticon(smiley) {
var txtarea = document.comments_form.text;
smiley = ' ' + smiley + ' ';
if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smiley + ' ' : smiley;
txtarea.focus();
} else {
txtarea.value  += smiley;
txtarea.focus();
}
}

//-->
</script>

2、在要显示表情图标按键的地方添加以下代码:
<style>

img.smiley {margin-bottom : 1px;
margin-left : 1px;
margin-top : 1px;
margin-right :1px;}
</style>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_biggrin.gif" alt="Very Happy" width="15" height="15" border="0" title="Very Happy" />')"><img src="http://mtblog.org/images/smiles/icon_biggrin.gif" alt="Very Happy" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_smile.gif" alt="Smile" width="15" height="15" border="0" title="Smile!" />')"><img src="http://mtblog.org/images/smiles/icon_smile.gif" alt="Smile" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_sad.gif" alt="Sad" width="15" height="15" border="0" title="Sad!" />')"><img src="http://mtblog.org/images/smiles/icon_sad.gif" alt="Sad" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_surprised.gif" alt="Surprised" width="15" height="15" border="0" title="Surprised!" />')"><img src="http://mtblog.org/images/smiles/icon_surprised.gif" alt="Surprised" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_eek.gif" alt="Shocked" width="15" height="15" border="0" title="Shocked!" />')"><img src="http://mtblog.org/images/smiles/icon_eek.gif" alt="Shocked" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_confused.gif" alt="Confused" width="15" height="15" border="0" title="Confused!" />')"><img src="http://mtblog.org/images/smiles/icon_confused.gif" alt="Confused" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_cool.gif" alt="Cool" width="15" height="15" border="0" title="Cool!" />')"><img src="http://mtblog.org/images/smiles/icon_cool.gif" alt="Cool" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_lol.gif" alt="Laughing" width="15" height="15" border="0" title="Laughing!" />')"><img src="http://mtblog.org/images/smiles/icon_lol.gif" alt="Laughing" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_mad.gif" alt="Mad" width="15" height="15" border="0" title="Mad!" />')"><img src="http://mtblog.org/images/smiles/icon_mad.gif" alt="Mad" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_razz.gif" alt="Razz" width="15" height="15" border="0" title="Razz!" />')"><img src="http://mtblog.org/images/smiles/icon_razz.gif" alt="Razz" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_redface.gif" alt="Embarassed" width="15" height="15" border="0" title="Embarassed!" />')"><img src="http://mtblog.org/images/smiles/icon_redface.gif" alt="Embarassed" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_cry.gif" alt="Crying or Very Sad" width="15" height="15" border="0" title="Crying or Very Sad!" />')"><img src="http://mtblog.org/images/smiles/icon_cry.gif" alt="Crying or Very Sad" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_evil.gif" alt="Evil or Very Mad" width="15" height="15" border="0" title="Evil or Very Mad!" />')"><img src="http://mtblog.org/images/smiles/icon_evil.gif" alt="Evil or Very Mad" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_twisted.gif" alt="Twisted Evil" width="15" height="15" border="0" title="Twisted Evil!" />')"><img src="http://mtblog.org/images/smiles/icon_twisted.gif" alt="Twisted Evil" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_rolleyes.gif" alt="Rolling Eyes" width="15" height="15" border="0" title="Rolling Eyes!" />')"><img src="http://mtblog.org/images/smiles/icon_rolleyes.gif" alt="Rolling Eyes" width="15" height="15" border="0" class="smiley"></a>
<a href="javascript:emoticon('<img src="http://mtblog.org/images/smiles/icon_wink.gif" alt="Wink" width="15" height="15" border="0" title="Wink!" />')"><img src="http://mtblog.org/images/smiles/icon_wink.gif" alt="Wink" width="15" height="15" border="0" class="smiley"></a><br />

重建页面后即可,具体效果可查看本站评论框。

在这推荐大家使用BbEdit 文章编辑插件,并结合结合MACRO优化该表情按键
BBEDIT插件包中有"符号转换html识别文件、本地表情图片、和结合Morcos后的smile代码(压缩包中的bb+smile)",大家可以直接复制使用。

Add a Reply

Forum Groups

Blogcs 基于MT平台的BSP

3 1

Last Topic: 本站的注册验证Email问题 by admin on 2008年11月20日

MovableType 中文化

1 0

Last Topic: Movable Type 中文化 - 平生一笑 by bb on 2008年10月11日

1 0

Last Topic: Zhu8's Weblog:猪八的网:浮生志 by Zhu8 on 2008年10月16日

MovableType 使用

16 13

Last Topic: Image::Magick 模块的安装 by bb on 2008年11月 9日

30 35

Last Topic: MT-Twitter:将MT文章同步到Twitter by bb on 2008年3月 9日

22 1

Last Topic: 修改MT的作者归档路径 by bb on 2008年10月25日

MovableType 模板

Be the first to post a topic in this forum

22 17

Last Topic: MovableType评论格式化 replies-to-replies by bb on 2008年10月15日

MovableType 延伸

14 17

Last Topic: 从Wordpress转移到Movabletype by bb on 2007年5月12日

3 4

Last Topic: dreamhost完美支持MT by kesor on 2008年11月24日

2 2

Last Topic: 最新版MovableType 4.22 已经发布 by bb on 2008年11月19日