ASP ImageButton OnClick 坐标

发布于 2024-08-13 18:07:45 字数 394 浏览 2 评论 0原文

我在 .Net 3.5 中有一个 ASP.Net ImageButton。这是一个大图像,450x700,用户可以单击。在服务器端,OnClick 事件处理程序根据用户单击的坐标执行一些操作。

这是一个基本地图,只是一个静态图像,用户可以单击。

它工作得很好,除非在 IE 中用户处于 100% 以外的缩放级别。在这种情况下,它会传递单击的实际像素坐标,这意味着我得到一个位于原点和单击点之间的线上某处的点。

事情,但是图像缩放时图像大小属性不会改变,image.Width 始终保持在 450。

我考虑做类似 actualX = clickedX * image.Width / 450的 我宁愿避免的 Javascript 黑魔法有什么方法可以找到与单击的点相对应的原始图像坐标?

I have an ASP.Net ImageButton in .Net 3.5. It's a large image, 450x700 that users can click on. On the server side, the OnClick event handler does some stuff based on the coordinates that the user clicks.

It's a basic map, just a single static image, that users can click on.

It works great, except when, in IE, the user is at a zoom level other than 100%. In that case, it passes the actual pixel coordinates of the click, meaning that I get a point that's somewhere on a line between the origin and the point of the click.

I looked at doing something like actualX = clickedX * image.Width / 450, but the image size properties don't change when the image is zoomed, image.Width always stays at 450.

Short of a bunch of Javascript black magic that I'd rather avoid is there any way to find the original image coordinates that correspond to the point that is clicked?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你穿错了嫁妆 2024-08-20 18:07:45

如果没有 JavaScript,服务器无法确定浏览器的缩放级别。

这听起来像是 IE 中的一个错误。放大页面应该对服务器完全透明。您应该向 Microsoft 报告此情况。

It is not possible for the server to determine the zoom level of the browser without Javascript.

This sounds like a bug in IE. Zooming in on the page should be completely transparent to the server. You should report this to Microsoft.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文