use javascript, for example:
<textarea name="txt1" rows="4" cols="40">Cache items with this priority level are the least likely to be deleted from the cache as the server frees system memory.</textarea>
<input type="text" name="txt2" value="<b>">
<input type="text" name="txt3" value="</b>">
<input type="button" value="insert" onclick="InsertText()">
<script>
function InsertText()
{
txt1.focus();
var re = document.selection.createRange();
re.text = txt2.value + re.text + txt3.value;
}
</script>
<textarea name="txt1" rows="4" cols="40">Cache items with this priority level are the least likely to be deleted from the cache as the server frees system memory.</textarea>
<input type="text" name="txt2" value="<b>">
<input type="text" name="txt3" value="</b>">
<input type="button" value="insert" onclick="InsertText()">
<script>
function InsertText()
{
txt1.focus();
var re = document.selection.createRange();
re.text = txt2.value + re.text + txt3.value;
}
</script>
解决方案 »
- asp.net实例下载地址
- 为了让更多的人能散200,散300分,决定把分全散了.......
- ★★★请问ASP.Net中,如何禁止webbrowser中的弹出对话框?
- 求助!为什么企业管理器能注册成功,但asp.net不能连接上这个sql server数据库?
- 有关日历控件的问题?
- 高分求《ASP.NET办公自动化系统开发实例导航》一书的CD下载
- 菜鸟问题,这是什么错误
- 求一个可以过滤除“_”和空格以外所有特殊字符的正则表达式
- MVC4 return View(model)后页面没有数据!
- 无法创建Web项目,也无法打开以前的项目了!!!救我!我上有老,下有小,中有老婆!
- 怎样设置dropdownlist的选中项
- 5分的题目。怎么转换URL?
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT>
function storeCaret(textEl)
{
if(textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret(textEl,text){
if(textEl.createTextRange && textEl.caretPos){
var caretPos = textEl.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
}
else
textEl.value = text;
}
</SCRIPT><META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<FORM name=aForm><TEXTAREA onkeyup=storeCaret(this); onclick=storeCaret(this); name=aTextArea rows=5 cols=80 onselect=storeCaret(this);>测试测试测试测试测试测试</TEXTAREA>
<BR><INPUT size=80 value=要插入的文字 name=aText> <BR><INPUT onclick=insertAtCaret(this.form.aTextArea,this.form.aText.value); type=button value=在光标处插入>
</FORM></BODY></HTML>
javescript要放在HTML页面中或在后台代码中直接输出到HTML中,不是直接写在后台代码中的
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="JavaScript">
Function Cuti(){
content.focus();
var re = document.selection.createRange();
re.text = "" + re.text + "";
}
</script>
<body>
<form name="news" method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><textarea name="content" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td><img src="pic/bold.gif" onClick="Cuti();" width="23" height="22"> </td>
</tr>
</table>
</form>
</body>
</html>
saucer(思归, MS .NET MVP) :上面的代码怎么不行?
function Cuti(){
document.news.content.focus();
var re = document.selection.createRange();
re.text = "" + re.text + "";
}
</script>