<DIV ID="a" contentEditable="true" style='border:1 solid black'>关于微软HTML编辑控件(也适用于可编辑的iframe)单击回车会插入<p>而不是<br>的解决方案</DIV> <p>
<div style='border:1 solid black' contentEditable="true">未经过脚本处理的编辑控件</div>
<script>
function a.onkeypress(){
if(event.keyCode==13){
var txtobj=document.selection.createRange()
txtobj.text==""?txtobj.text="\n":(document.selection.clear())&(txtobj.text="\n")//三目复合表达式,解决有被选文字时回车的光标定位问题
document.selection.createRange().select()
return false
}}
</script>
网页编辑器中的换行Enter跨行问题解决方案
最新推荐文章于 2024-04-01 15:07:25 发布