我在网页中添加了一个右键菜单项,给他的contexts内容是0x4(只能分辨控件),名称“addtext”,然后选中会调用相应的htm文件,并往网页的文本框输入信息。
请问,如何判别右键的输入框是password属性的?如何实现在右键不同属性的文本框,如password能调用不同htm输入password?(换句话说在鼠标右键的时候,就能判断出这个输入框为password属性)

解决方案 »

  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>
        document.onmousedown=getType;
        document.onmouseup=clearobj;
        var obj;
        function getType()
        {
             if(event.button==2)
             {
                obj=event.srcElement;
                alert(obj.type);
             }
            
        }
        function clearobj()
        {
            obj='';
        }
        </script>
    </head>
    <body>
    <input type="text" oncontextmenu="return(false)"  />
    <input type="password" oncontextmenu="return(false)" />
    </body>
    </html>楼主想要的效果