摘要:
Selection对象,表示当前激活的高亮文本选区.Selection对象获取标本浏览器 : window.getSelection();IE : document.selection;兼容代码:var selection = window.getSelection ? window.getSelection() : document.selection;Selection对象取消选区if(selection.removeAllRanges){ selection.removeAllRanges();} else{ selection.empty();} 阅读全文
posted @ 2014-01-12 13:20
_彭建
阅读(241)
评论(0)
推荐(0)
摘要:
元素拖动前提条件:元素为定位元素, 个人建议position:absolute;算法1var left,top,x,y;var element = document.getElementById('drag');element.onmousedown = function(e){ e = e || window.event; left = this.offsetLeft; top = this.offsetTop; x =e.clientX; y =e.clientY; this.addEventListener('mousemove',dragMove,fal 阅读全文
posted @ 2014-01-12 12:57
_彭建
阅读(774)
评论(0)
推荐(0)
摘要:
Event兼容性代码,按照W3C标准兼容:var fixEvent = function(e){ e = e || window.event; if(!e.preventDefault){ e.preventDefault = function(){ event.returnValue = false; }; } if(!e.stopPropagation){ e.stopPropagation = function(){ event.cancelBubble = true; }; } if(e.pageX === undefined && e.pag... 阅读全文
posted @ 2014-01-12 11:17
_彭建
阅读(136)
评论(0)
推荐(0)

浙公网安备 33010602011771号