光标处插入图片(类似于qq表情)

a.jsp:
<%@ page contentType="text/html; charset=gbk" pageEncoding="gbk"%>
<%@ page import="java.util.*"%>

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>

<HTML>
<HEAD>
  <TITLE> 光标出插入图片 </TITLE>
</HEAD>

<BODY>
<table>
<!-- 增加表情功能 start-->
  <tr>
<td valign="top">表情:</td>
<td>
  <%for(int i = 0; i < 96; i ++){%>
<img src="/images/QQ/<%=i%>.gif" style="cursor:hand" onmouseout="mOut(this)" onmouseover="mOver(this)" onclick="ck(this)">
  <%}%>

</td>
  </tr>
<!-- 增加表情功能 end-->
<tr>
<td>
<textarea id="txtContent" rows="10" style="width:90%"></textarea>
</td>
</tr>
</table>
</BODY>
</HTML>

<script language="javascript">
  function mOut(obj) {
var src = obj.src;
src = src.replace("fixed.bmp", ".gif");
obj.src = src;
  }
  function mOver(obj) {
var src = obj.src;
src = src.replace(".gif", "fixed.bmp");
obj.src = src;
  }
  function ck(obj) {
var src = obj.src;
src = src.replace("fixed.bmp", ".gif");
txtContent.insertHTML("<img src=" + src + ">");
  }

</script>

你可能感兴趣的:(html,jsp,qq,cache)