不知道是不是你要的
<img src="/inc/face1/emot-04.gif" onclick="addEmot(this)" alt="牛" width="50" height="50" border="0" />
<img src="/inc/face1/emot-05.gif" onclick="addEmot(this)" alt="牛" width="50" height="50" border="0" />
<script language="javascript">
function addEmot(obj)
{
var sImgPath = "<IMG src='" + obj.src +"' border=0>";
eWebEditor1.appendHTML(sImgPath);
}
</script>
<img src="/inc/face1/emot-04.gif" onclick="addEmot(this)" alt="牛" width="50" height="50" border="0" />
<img src="/inc/face1/emot-05.gif" onclick="addEmot(this)" alt="牛" width="50" height="50" border="0" />
<script language="javascript">
function addEmot(obj)
{
var sImgPath = "<IMG src='" + obj.src +"' border=0>";
eWebEditor1.appendHTML(sImgPath);
}
</script>
function editimg(ids){
document.getElementById(ids).onclick=function(o){showimg(o,ids);}
}
function showimg(o,ids){
var o = o || window.event;
var obj=o.target || o.srcElement;
if (obj.tagName=="IMG"){
var url;
url=obj.src;
document.getElementById("myInstance1").innerHTML+="<img src="+url+">";
}
}window.onload=function(){
editimg("countrydivcontainer");
}
</SCRIPT>
<DIV id=countrydivcontainer><img src="/inc/face1/emot-04.gif" alt="牛" width="50" height="50" border="0"><img src="/inc/face1/emot-03.gif" alt="流汗" width="50" height="50" border="0"><img src="/inc/face1/39.gif" alt="再见" width="50" height="50"><img src="/inc/face1/emot-09.gif" alt="晕死" width="50" height="50"><br><img src="/inc/face1/emot-51.gif" alt="拍死你" width="50" height="50"><img src="/inc/face1/emot-52.gif" alt="水草舞" width="50" height="50"><img src="/inc/face1/emot-16.gif" alt="发狂骂人" width="50" height="50"><img src="/inc/face1/emot-59.gif" alt="色" width="50" height="50"><br><img src="/inc/face1/emot-29.gif" alt="恭喜男" width="50" height="50"></DIV>分析以上俩段代码实现点击图片后 把值付给编辑区myInstance1内
完全实现 图片 和 JS 的分离,我以前一直用的,现在我由于 编辑器的改变,不兼容了(原来的编辑器可以),
document.getElementById("myInstance1").innerHTML+="<img src="+url+">";被我改为
//document.eWebEditor1.appendHTML('<img src="+url+">')
eWebEditor1.appendHTML('<img src="+url+">')
//document.getElementById("myInstance1").innerHTML+="<img src="+url+">";
// document.getElementById("b_cont").innerHTML+="<img src="+url+">";
上面四行代码我都测试了,都不行,郁闷啊
<SCRIPT language=JavaScript type="text/javascript">
function editimg(ids){
var objs = document.getElementsByTagName("IMG");
for(var i=0,j=objs.length;i<j;i++){
objs[i].onclick=function(o){showimg(o,ids);}
}
}
function showimg(o,ids){
var o = o || window.event;
var obj=o.target || o.srcElement;
var sImgPath = "<IMG src='" + obj.src +"' border=0>";
eWebEditor1.appendHTML(sImgPath);
//if (obj.tagName=="IMG"){
// var url;
//url=obj.src;
// document.getElementById("myInstance1").innerHTML+=" <img src="+url+">";
//}
} window.onload=function(){
editimg("countrydivcontainer");
}
</SCRIPT>
<DIV id=countrydivcontainer> <img src="/inc/face1/emot-04.gif" alt="牛" width="50" height="50" border="0"> <img src="/inc/face1/emot-03.gif" alt="流汗" width="50" height="50" border="0"> <img src="/inc/face1/39.gif" alt="再见" width="50" height="50"> <img src="/inc/face1/emot-09.gif" alt="晕死" width="50" height="50"> <br> <img src="/inc/face1/emot-51.gif" alt="拍死你" width="50" height="50"> <img src="/inc/face1/emot-52.gif" alt="水草舞" width="50" height="50"> <img src="/inc/face1/emot-16.gif" alt="发狂骂人" width="50" height="50"> <img src="/inc/face1/emot-59.gif" alt="色" width="50" height="50"> <br> <img src="/inc/face1/emot-29.gif" alt="恭喜男" width="50" height="50"> </DIV>
document.getElementById("myInstance1").innerHTML+=" <img src="+url+">"; 部分
zjsfdxbao 你的这行不行(已经 去除代码中//)
现在引入部分代码为
<td width="235"><input type="hidden" name="b_cont" value="">
<iframe ID="eWebEditor1" src="/eWebEditor/ewebeditor.htm?id=b_cont&style=yellow" frameborder="0" scrolling="no" width="545" HEIGHT="400"></iframe></td>