如何捕捉x和y的位置,并精确地在MVC4中重新定位?
  可能重复: 
  动态检索HTML元素的位置(X,Y) 
在一个MVC4应用程序(针对IE7 +),我有一个图像。 我希望用户能够点击图像来定位一个小标记(图像),并且我想存储与图像相关的相对x / y位置,这样我可以在用户返回此页面时重新定位此引脚再次。
什么是完成这个最好的方法?
  你可以使用一个<input type="image" />标签 - 这就像<input type="submit" />但它将点击的x和y坐标发送回服务器。 
视图
<h1>Click on the image to place a pin</h1>
@using(Html.BeginForm())
{
    <input type="image" name="coords" src="http://placehold.it/300x300" />
}
调节器
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
    [HttpPost]
    public ActionResult Index(FormCollection form)
    {
        int x = int.Parse(form["coords.x"]);
        int y = int.Parse(form["coords.y"]);
        // FIXME Save location of pin
        return View();
    }
}
上一篇: How to catch x and y position and reposition exactly in MVC4?
