繁体   English   中英

Javascript-通过电线在文档上“打印”鼠标

[英]Javascript - “print” mouse on document by cords

我有鼠标线列表(x,y)因为无法用javascript移动鼠标,所以我想在document上打印假鼠标,然后再打印已有的线。

可能吗? 怎么样?

我的解决方案是打印显示鼠标的PNG并使用CSS隐藏原始鼠标:

 createCursor: function() {
                var cursor = document.createElement("img");
                cursor.src = chrome.extension.getURL('pics/cursor.png');
                cursor.style.zIndex = "9999";
                cursor.setAttribute("id", "recordMeCursor");
                var body = document.getElementsByTagName("BODY")[0];
                body.style.cursor = 'none';
                body.appendChild(cursor);
            },
 moveCursor: function(cords, i, callback) {
                var cursor = document.getElementById("recordMeCursor");
                setTimeout(function() {
                    cursor.style.position = "absolute";
                    cursor.style.left = cords.x+'px';
                    cursor.style.top =cords.y+'px';
                    return callback('OK');
                }, i * 50);

            },
 destroyMouse: function() {
                var cursor = document.getElementById("recordMeCursor");
                cursor.parentNode.removeChild(cursor);
                var body = document.getElementsByTagName("BODY")[0];
                body.style.cursor = 'default';
            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM