<IMG SRC="temp.gif" WIDTH="1024" HEIGHT="478" BORDER=0 onclick="alert(event.offsetX + '---' + event.offsetY)">

解决方案 »

  1.   

    offsetX Property
    --------------------------------------------------------------------------------
    Retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event. clientY Property
    --------------------------------------------------------------------------------
    Retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
      

  2.   

    <form name="myform" action="test.asp">
    <input name="tt" type="image" src="images/test.gif" value="1" onclick="ss()" />
    </form>
    <script>
    function ss(){
      alert("x="+event.offsetX+"\ny="+event.offsetY);
      event.returnValue=false;
    }
    </script>
      

  3.   

    onclick=functionname(event)//event就是一个对象,可以读出坐标值functionname(event)
    {
    document.forms['myform'].action="tesp.aspx?x="+event.screenX+"&y="+event.screenY;
    //再提交窗体,不知有无SUMBIT()方法,不想试了,若没有建一SUMBIT按钮,模拟它的点击事件 //SUMBITNAME.CLICK()
    }
      

  4.   

    忘了说了.这里不能使用 event 对象.多谢 LxcJie(肖冲*爱*捷捷) 和 swzlxm(leon.net) 的解答.继续关注.
      

  5.   

    不是点击以后拿到坐标吗?不使用event是拿不到坐标的啊
      

  6.   

    不使用 event ,用<input type="image"...>会提交一个请求,那个地址后面有鼠标坐标.我想取到那个值...你可以测试一下.
      

  7.   

    index.htm<form action='result.htm'>
    <input type="image">
    </form>
    result.htm<SCRIPT LANGUAGE="JavaScript">
    <!--
    var str = location.search;
    var params = str.split("?")[1];
    var arrPara = params.split("&");
    alert("x:" + arrPara[0].split("=")[1]);
    alert("y:" + arrPara[1].split("=")[1]);
    //-->
    </SCRIPT>
      

  8.   

    多谢 LxcJie(肖冲*爱*捷捷) 你的解答..我现在就是这样做的.但是这样要到服务器请求一起,页面大的时候只因为鼠标坐标请求效率太低..想寻一个不提交就取得该鼠标的方法.不知道谁做过...这应该是低版本就具有的一个功能,我以前都没有发现可以这样取坐标...
      

  9.   

    try this:  禁止自动提交,自己提交<form method="post">
    <input type="image" onclick="subForm()">
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function subForm()
    {
        event.returnValue = false;
        alert("x:" + event.offsetX + "\n" + "y:" + event.offsetY);
    //    document.forms[0].action = "result.jsp?x=" + event.offsetX + "&y=" + event.offsetY;
        document.forms[0].action = "result.jsp";
        document.forms[0].submit();
    }
    //-->
    </SCRIPT>
    </form>
      

  10.   

    这里面含有event.offsetX 和 event.offsetY,所以用不了啊。继续关注
      

  11.   

    你自己再发挥发挥:
    <form name="myform" action="test.asp" onsubmit="alert(action); return false;">
    <input name="tt" type="image" onclick="mz(this)"
      src="http://community.csdn.net/images/CSDN_logo.gif">
    </form><SCRIPT LANGUAGE="JavaScript">
    function getAbsLeft(e){var l=e.offsetLeft; while(e=e.offsetParent) l += e.offsetLeft; return l;}
    function getAbsTop(e) {var t=e.offsetTop;  while(e=e.offsetParent) t += e.offsetTop;  return t;}
    //上面这两个函数是取得控件在页面里的绝对位置
    function mz(e)
    {
      alert("你鼠标点击的坐标:\r\nx="+ window.event.clientX +"  y="+ window.event.clientY);
      var top = getAbsTop(e);
      var left= getAbsLeft(e);
      document.myform.action = "test.asp\?x="+ left +"&y="+ top;
    }
    </SCRIPT>
      

  12.   

    个人观点:
       只要点击了,就产生了event,不用event取值的话,而且又不提交,仿佛不能取得值.
       难道可以用其他方式取的event产生的值,关注这个答案!
      

  13.   

    获取坐标
    function GetDefineX(ObjectID)
    {
    var iPositionX=ObjectID.offsetLeft;
    while(ObjectID=ObjectID.offsetParent)
    {
    iPositionX+=ObjectID.offsetLeft;
    }
    return iPositionX;
    }
    function GetDefineY(ObjectID)
    {
    var iPositionY=ObjectID.offsetTop;
    while(ObjectID=ObjectID.offsetParent)
    {
        iPositionY+=ObjectID.offsetTop;
    }
    return iPositionY;
    }
    自己提交
    <style>
    input.Button_Gif{height:23px; width:65; background-color: white;color: #6D869A; background-image:url(button.gif);font-size: 9pt; border:0px solide white; background-repeat: no-repeat; text-align: center; cursor:hand; padding-top:0px; vertical-align:top;}
    </style>
    <input type=button value="美丽按钮" class="Button_Gif" onclick="document.forms[0].submit();">
    什么时间获取坐标随意啊.
      

  14.   

    To:netfound(网络虫冲)我现在环境是不支持 window.event 对象(所以根本就没有 clientX 之类的值).所以取不到鼠标.但是通过<input type="image"...>会自动提交一个鼠标坐标到action中.你可以测试一下..我就是想取到那个坐标..
      

  15.   

    PocketPC Internet Explore 
    即PIE
      

  16.   

    是不是可以就<input type="image"...>或者<img src=".." ISMAP>进行讨论?The ISMAP attribute is used with server-side image maps. When the ISMAP attribute is included with a linked image and the user clicks the image, the image coordinates clicked are sent to the server, from which a location can be returned.
      

  17.   

    另外除了event外还有没有办法获得...
      

  18.   

    <form name="myform" action="test.asp">
    <img name="tt"   src="http://community.csdn.net/images/CSDN_logo.GIF" value="1" />
    <input name="ds"  >
    </form>
    <SCRIPT LANGUAGE=vbscript>
     
    alert(myform.tt.offsetTop) 
     
    </SCRIPT>
    把input  type=image换成img就可以了。
      

  19.   

    我试了一下,功能差不多。有两种选择
    一、
    <form name="myform" action="test.asp">
    <input type="image" name="tt" src="http://community.csdn.net/images/CSDN_logo.GIF"/>
    </form>点击后的action会变成test.asp?tt.x=5&tt.y=8提交,如果不提交则没有"?tt.x=t&tt.y=8"二、
    <a href="test.asp"><img src="http://community.csdn.net/images/CSDN_logo.GIF" ismap></a>
    点击后会以test.asp?5,8的形式转到下个超链接另外 这两种情况在HTML2.0 里面应该就支持了,所以大家不用担心平台的问题,我暂时就用第二种,要是有javascript取得这个值的方法不妨介绍一下啊。up者有分
      

  20.   

    event.x
    event.y
    不能取得坐标?IE的好象都可以~
      

  21.   

    Pocket IE 没有这个对象,我测试过了
    alert(window.event);什么也没有,在 IE 下面是[object]
      

  22.   

    没找到办法,就用处理URL的办法来作了.
    十分感谢各位的解答.