zoukankan      html  css  js  c++  java
  • JS 获取鼠标坐标

    <style type="text/css">        
         #imgFrame{ position:absolute; top:30%; left:40%; z-index:1000; display:none;}     
    </style> 
    
    <script type="text/javascript">         
    function showOriginal(img,e) 
    {
       //鼠标x坐标
    // document.getElementById("imgFrame").style.top = mousePos(e).x;    //鼠标Y坐标
    // document.getElementById("imgFrame").style.left = mousePos(e).y; // document.getElementById("imgFrame").style.zIndex=1000; // document.getElementById("imgFrame").style.position = "absolute"; document.getElementById("imgFrame").style.display = "block"; document.getElementById("imgbox").innerHTML = "<img src='" + img + "' />"; } function close() { document.getElementById("imgFrame").style.display = "none"; } //获取鼠标坐标 function mousePos(e){ var x,y; var e = e||window.event; return { x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft, y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop }; }; function test(e)
    {

      document.getElementById("mjs").innerHTML = mousePos(e).x+','+mousePos(e).y;   

    }; </script>

    <img src='<%#Eval("picture")%>' width="100" height="50" onclick="showOriginal('<%#Eval("picture")%>',event);">

    <div id="test" style="1000px;height:1000px;background:#ccc;" onmousemove="test(event)"></div>

  • 相关阅读:
    node.js中的全局变量——global
    Element-UI库 源码架构浅析
    如何搭建一个自己cli
    webpack实践之DLLPlugin 和 DLLReferencePlugin
    HappyPack优化
    线程和进程
    kafka?kafaka! kafka...
    Dubbo的初步理解和使用
    Redis的安装和启动
    解析Spring MVC上传文件
  • 原文地址:https://www.cnblogs.com/lengv10/p/3656162.html
Copyright © 2011-2022 走看看