1、文本框内容为“你好!”;
2、现在要插入表情“A”,插入后,文本内容为“A你好!”;
3、现在再插入表情“B”,插入后,文本内容为“BA你好!”;
4、现在再插入表情“C”,插入后,文本内容为“CBA你好!”;我想让它变为“你好!ABC”,这个怎么改呢?
插入表情代码:
var editor = null;//输入框
var viewer = null;//显示位置
var face = null;
..........................
//=========================================================================================
// 显示表情
function viewFace()
{
face.style.visibility = "visible";
}
// 隐藏表情
function hiddenFace()
{
face.style.visibility = "hidden";
}
// 插入表情
function insertFace(img)
{
hiddenFace();
editor.focus();
editor.document.execCommand('InsertImage',false,img);
//editor.document.execCommand('Unselect');
}
//-----------------------------------
2、现在要插入表情“A”,插入后,文本内容为“A你好!”;
3、现在再插入表情“B”,插入后,文本内容为“BA你好!”;
4、现在再插入表情“C”,插入后,文本内容为“CBA你好!”;我想让它变为“你好!ABC”,这个怎么改呢?
插入表情代码:
var editor = null;//输入框
var viewer = null;//显示位置
var face = null;
..........................
//=========================================================================================
// 显示表情
function viewFace()
{
face.style.visibility = "visible";
}
// 隐藏表情
function hiddenFace()
{
face.style.visibility = "hidden";
}
// 插入表情
function insertFace(img)
{
hiddenFace();
editor.focus();
editor.document.execCommand('InsertImage',false,img);
//editor.document.execCommand('Unselect');
}
//-----------------------------------
解决方案 »
- 【紧急】:IE8下iframe子窗口通过top访问顶层窗口的时候报"没有权限"
- 哪位兄弟,帮我看看菜鸟代码,有重谢!!!
- javascript
- 请教js中的asc码 谢谢!
- 求助js高手..
- 请问现在还有不被拦截的弹窗代码吗?或者能躲过上网助手和tt,myie的
- @@@@@@@@@@@@@@@@@@@@@@@怎么做一个统计文本框字数的 程序
- 求可任意拖动的,不驻留在任务栏,纯JAVASCRIPT的模拟QQ菜单代码!不甚感激!
- 在JavaScript中调用new ActiveXObject("Scripting.FileSystemObject")会涉及安全问题吗?
- 急!!!请问在List/Menu中,选择不同选项,如何弹出不同页面,在线等待!
- 请教关于IE、firefox、chrome以及opera等不同浏览器的iframe的高度兼容问题
- 满意加分!FCKeditor 问题
function insertFace(img)
{
hiddenFace();
editor.focus();
editor.value = editor.value;//加这行试一试
editor.document.execCommand('InsertImage',false,img);
//editor.document.execCommand('Unselect');
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jsKmユ・/title><script>
function set11(){
document.form1.txt1.focus();
var range = document.selection.createRange();
range.moveStart( "textedit", 1 );
range.moveEnd( "textedit", 1 );
range.select();
}
</script>
</head>
<body>
<form id="form1" name="form1">
<input id="txt1" name="text1"value="sdfsdf,sdf,ede" /><br />
<input type=button onclick="set11()">
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">var editor = null;//输入框
var viewer = null;//显示位置
var face = null;//=========================================================================================
// 显示表情
function viewFace()
{
face.style.visibility = "visible";
}
// 隐藏表情
function hiddenFace()
{
face.style.visibility = "hidden";
}
// 插入表情
function insertFace(img)
{
//hiddenFace();
editor.focus();
editor.value = editor.value;
//editor.document.execCommand('InsertImage',false,img);
//editor.document.execCommand('Unselect');
}
</script>
</head>
<body>
<form name="myForm">
<div><input type="text" name="input1" value="有一段话" /></div>
<input type="button" onclick="insertFace()" value="确定" />
</form>
</body><script>
editor = document.forms["myForm"].elements["input1"];
</script>
</html>
可能是因为这句editor.document.execCommand('InsertImage',false,img);的原因
没这句文本框的焦点是在末尾的
比如:
a="x";
a="y"+a;
a="z"+a;
而JavaScript中根据document.getElementById("inputId").value就代替上边的a就可以实现的。