有没有办法告诉Chrome网页调试器在页面坐标中显示当前的鼠标位置? [英] Is there a way to tell Chrome web debugger to show the current mouse position in page coordinates?

查看:2523
本文介绍了有没有办法告诉Chrome网页调试器在页面坐标中显示当前的鼠标位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用Chrome网页调试器调试我的JavaScript代码。在元素选项卡中,将鼠标悬停在元素上显示一些包含该元素的宽度和高度的工具提示。



有时我需要看到当前鼠标位置的页面坐标。但是似乎调试器不显示这种信息。



那么,有没有办法添加?像扩展名,还是还有其他选项?



编辑



接受的答案我可以添加以下书签,并且正是我想要的:

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆