DW鼠标光标偏移问题

Dreamweaver中文定位问题,Dreamweaver选择中文代码时光标位置不对问题,Dreamweaver选择中文代码时光标定位不对问题

终于解决困扰多时的问题了,谢谢登高望远博主!

    最近在使用DW的时候,在代码编辑区, 如果有中文时, 用鼠标点击时, 光标的落位总是不准确, 总要往前偏位几个字符. 光标偏位了.  开始还不在意, 以为是因为系统的太慢, 用得久了, 有点延迟. 重新启动系统和软件还是这样. 开始发现是Dreamweaver软件的问题.

    可以说这里因为Dreamweaver中文支持不好所产好的问题, 我们知道当在utf8编码下, 中文是占两个字符的位置的. 我猜测可能DW没有考虑到这个, 在代码编辑区把所有的文字做统一长度来处理, 也把中文也当作是一个字符位. 导致光标定位的时候不准确.

    找到问题的所在, 解决起来就简单了, 就是要把代码编辑区的字体全部设置统一的字体, 把Unicode的字体也设置成简体中文的一样, 都用宋体, 如下图:

DW鼠标光标偏移问题 - 网站笔记 - 网站笔记的博客

    这样设置以后, 代码编辑区的字体跟着变化, 都统一了宋体作为显示字体. 就不会产生光标偏位和光标位置不对的问题了.

function calendar()//主调函数 { var e = window.event.srcElement; writeIframe (); var o = WebCalendar.calendar.style; WebCalendar.eventSrc = e; if (arquments.length == 0) WebCalendar.objExport = e; else WebCalendar.objExport =eval(arquments[0]); WebCalendar.iframe.tableWeek.style.cursor = WebCalendar.draq ? "move" : "default"; var t = e.offsetTop, h = e.clientHeight, l = e.offsetLeft, p = e.type; while (e = e.offsetParent){t += e.offsetTop; l += e.offsetLeft;} o.display = ""; WebCalendar.iframe.document.body. focus () ; var cw = WebCalendar.calendar.clientWidth, ch = WebCalendar.calendar.clientHeight; var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop; if (document.body.clientHeight + dt - t - h >= ch) o.top = (p=="image")? t + h : t + h + 6; else o.top = (t - dt < ch) ? ((p=="image")? t + h :t + h + 6) :t - ch; if (dw + dl - l >= cw) o.left = l; else o.left = (dw >= cw) ? dw - cw + dl : dl; if (!WebCalendar.timeShow) WebCalendar.dateReg = /^(\d{1, 4}) (-1\/) (\d{1, 2}) \2(\d{1, 2})$/; else WebCalendar.dateReg = /^(\d{1, 4}) (-1\/) (\d}1, 2})\2(\d{1, 2}) (\d{1, 2}): (\d{1, 2}): (\d{1, 2})$/; try { if (WebCalendar.objExport.value.trim() != ""){ WebCalendar.dateStyle = WebCalendar.objExport.value.trim() .match (WebCalendar.dateReg) ; if (WebCalendar.dateStyle == null) {WebCalendar.thisYear = new Date().getFullYear () ; WebCalendar.thisMonth = new Date().getMonth()+ 1; WebCalendar.thisDay = new Date().getDate(); alert("无效的日期格式!”); writeCalendar(); return false;} else{ WebCalendar. thisYear = parseInt (WebCalendar.dateStyle[1], 10); WebCalendar.thisMonth = parseInt (WebCalendar .dateStyle[3], 10); WebCalendar.thisDay = parseInt (WebCalendar.dateStyle[4], 10); WebCalendar. inputDate=parseInt (WebCalendar.thisMonth, 10) +"/"+ parseInt (WebCalendar.thisDay, 10) +”/"+ parseInt(WebCalendar.thisYear, 10) ; writeCalendar() ; }}else writeCalendar () ; } catch(e) (writeCalendar () ;} } 给上述代码添加注释的注释,并解释相关方法
最新发布
03-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值