我想通过鼠标点击表单上面的元素,获取该元素的属性值,就是window.document.xxx.xxx这种形式的?要如何实现呢?我想到的方法:
1.通过注册表触发鼠标点击事件(不知道有没有相关注册表),然后通过js获取(如何获取)2.通过windows自带的鼠标命令,然后获取(具体怎么实现,没思路....)我看qtp上有spy这个获取表单元素的功能 我想自己实现下应该可以把?
有没有高手来点思路的?

解决方案 »

  1.   

    没看懂楼主的意思,说得有点像在做软件似的!不知道是否这样的意思?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
        <script type="text/javascript">
        function onLoad(){
     document.getElementById("t1").onclick=function(){alert(this.value);}
     document.getElementById("t2").onclick=function(){alert(this.value);}
     }
        </script>
    </head>
    <body onload="onLoad()">
    <div id="myDiv">
        <input type="text" id="t1" value="v1" />
        <input type="text" id="t2" value="v2" />
    </div>
    </body>
    </html>
      

  2.   

    使用
    利用你想起作用的表单对象调用方法onclick
    例如:
    doc.onclick=fun;下面是方法,记住调用的时候不懈框号,不加引号(doc.onclick=fun;)
    function fun(){
       
    }
      

  3.   

    不是这个意思。可能我说的有问题吧?
    换一种说法,现在我想实现的第一步,是通过脚本语言对任意表单上面的任意文本框赋值(通过鼠标选择)?用js可以实现吗?我看js都是内嵌的形式对当前的表单进行操作的,有没有直接执行某个脚本 就可以对当前鼠标所选择的文本框赋值的?
      

  4.   

    <html>
    <head>
    <title>test</title>
    <script>
    window.onload=function(){
      document.body.onclick=function(){
    alert(document.elementFromPoint(event.x,event.y).type);
    }
    }
      </script>
    </head>
    <body >
    <form>
    <input type="button" value="click">
    <input type="radio" name="" value="">
    <input type="text" >
    <input type="password" >
    <input type="checkbox" name="" value="">
    </form>
    </body>
    </html>