有没有办法告诉Chrome网页调试器在页面坐标中显示当前的鼠标位置? [英] Is there a way to tell Chrome web debugger to show the current mouse position in page coordinates?
问题描述
有时我需要看到当前鼠标位置的页面坐标。但是似乎调试器不显示这种信息。
那么,有没有办法添加?像扩展名,还是还有其他选项?
编辑
接受的答案我可以添加以下书签,并且正是我想要的:
javascript:document.onmousemove = function(e){ var x = e.pageX; var y = e.pageY; e.target.title =X是+ x +,Y是+ y;};
您可以在控制台中输入,
document.onmousemove = function(e){
var x = e.pageX;
var y = e.pageY;
e.target.title =X是+ x +,Y是+ y;
};
这将给您鼠标在元素工具提示中移动的位置。
I often debug my javascript code using the Chrome web debugger. In the elements tab, hovering over an element show a tooltip with a few pieces of information, including the width and the height of that element.
Sometimes, I need to see the page coordinates of the current mouse position. But it seems the debugger does not display this kind of information.
So, is there a way to add it? Like an extension or maybe there are other options?
EDIT
Using the accepted answer I could add the following bookmarklet and have exactly what I wanted:
javascript:document.onmousemove = function(e){var x = e.pageX;var y = e.pageY;e.target.title = "X is "+x+" and Y is "+y;};
You could type this into the console,
document.onmousemove = function(e){
var x = e.pageX;
var y = e.pageY;
e.target.title = "X is "+x+" and Y is "+y;
};
This will give you mouse position on mouse move in the element tooltip.
这篇关于有没有办法告诉Chrome网页调试器在页面坐标中显示当前的鼠标位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!