zoukankan      html  css  js  c++  java
  • 浏览器获取鼠标光标坐标

    function getSelectionCoords(win) { 
      win = win || window;
      var doc = win.document; 
      var sel = doc.selection, range, rects, rect; 
      var x = 0, y = 0; 
      if (sel) { 
        if (sel.type != "Control") { 
          range = sel.createRange(); 
          range.collapse(true); 
          x = range.boundingLeft; 
          y = range.boundingTop; 
        } 
      } else if (win.getSelection) { 
        sel = win.getSelection(); 
        if (sel.rangeCount) { 
          range = sel.getRangeAt(0).cloneRange(); 
          if (range.getClientRects) { 
            range.collapse(true); 
            rects = range.getClientRects(); 
            if (rects.length > 0) {
              rect = rects[0]; 
            } 
            if(rect){ 
              x = rect.left; 
              y = rect.top; 
            } 
          }
          if ((x == 0 && y == 0) || rect === undefined) { 
            var span = doc.createElement("span"); 
            if (span.getClientRects) {
              span.appendChild(doc.createTextNode("u200b")); 
              range.insertNode(span); 
              rect = span.getClientRects()[0]; 
              x = rect.left; 
              y = rect.top; 
              var spanParent = span.parentNode; 
              spanParent.removeChild(span);
              spanParent.normalize(); 
            } 
          } 
        } 
      } 
      return { x: x, y: y }; 
    }
  • 相关阅读:
    ORA-00119: invalid specification for system parameter LOCAL_LISTENER
    local_listener参数的作用!
    DDL为什么不能rollback?
    LGWR和DBWn的触发条件
    修改spfile位置
    初识oracle重做日志文件
    ORACLE AUDIT 审计
    Oracle SQL_TRACE使用小结
    Web API(六):使用Autofac实现依赖注入
    JavaScript:属性的操作
  • 原文地址:https://www.cnblogs.com/litings/p/13862396.html
Copyright © 2011-2022 走看看