获取div光标并插入图片
//显示图片function showImage(div_id,img_src) { //IE support if (document.selection) { var myField = document.getElementById(div_id); //对象 var myValue = '<img src = "'+img_src+'"/>'; //值 myField.focus(); var sel = document.selection.createRange(); sel.pasteHTML(myValue); }else { var sel = div_range; if(sel == null || sel == 'undefined'){ myfocus(div_id); sel = document.getSelection().getRangeAt(0); } var img = document.createElement("img"); img.src = img_src; sel.insertNode(img); }}var div_range;function divOnmouseout(){var sel = document.getSelection();if(sel){//ff,chdiv_range = sel.getRangeAt(0);}//获取焦点function myfocus(obj) { if (typeof obj == 'string') obj = document.getElementById(obj); obj.focus(); if (obj.createTextRange) {//ie var rtextRange = obj.createTextRange(); if(obj.value == null || obj.value == '') return; rtextRange.moveStart('character', obj.value.length); rtextRange.collapse(true); rtextRange.select(); }else if (obj.selectionStart){//chrome "<input>"、"<textarea>" obj.selectionStart = obj.value.length; }else if(window.getSelection){ var sel = window.getSelection(); var tempRange = document.createRange(); if(obj.firstChild == null || obj.firstChild == '') return; tempRange.setStart(obj.firstChild, obj.firstChild.length); sel.removeAllRanges(); sel.addRange(tempRange);}}}