admin管理员组文章数量:1135133
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;};
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;};
Share
Improve this question
edited Sep 16, 2015 at 17:56
ppsreejith
3,4282 gold badges26 silver badges27 bronze badges
asked Oct 15, 2012 at 2:36
markmark
62.5k94 gold badges339 silver badges663 bronze badges
3 Answers
Reset to default 185You 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.
Combining ppsreejith's answer with JHarding's answer with Chrome 70+'s Live Expressions you can get constantly updating (x, y)
coordinates without filling up the devtools console:
Enter this in the console:
var x, y; document.onmousemove=(e)=>{x=e.pageX;y=e.pageY;}
Enter this as a Live Expression (to create a Live Expression, click on the eye in the top menu of the console).
"("+x+", "+y+")"
And this works on SVGs.
When i need to see the coordinates for my mouse, i use this Chrome addon: Coordinates addon
本文标签:
版权声明:本文标题:javascript - Is there a way to tell Chrome web debugger to show the current mouse position in page coordinates? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736910502a1956125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论