添加一个javascript var并发送邮件

时间:2013-05-10 10:30:35

标签: php javascript html

我有这段代码:

$image_action = $_POST['image_action'];   
echo '  
<form action="" method=post onmousedown="rightbutton(event)">
<input type="image"  
            src="image.jpeg"  
            style="cursor:crosshair"  />   
        </form>      '; 

<script type="text/javascript">
function rightbutton(event)
{
    if(event.button==2) {  document.getElementById("click").innerHTML="Last action: Right Click";  }
    else{
        if(event.button==0) {  document.getElementById("click").innerHTML="Last action: Left Click";  }  
        else {
            if(event.button==1) {  document.getElementById("click").innerHTML="Last action: Middle Click";  }
        }
    }

}
</script>

好吧,我正在尝试做的是获取用户在新页面中点击了哪个鼠标按钮的信息,因此在新页面中,我会相应地做不同的事情。我试图做这样的事情:

method = method || "post";
var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", image_action);
    hiddenField.setAttribute("value", event);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();

但是我收到了错误:Undefined index: key

0 个答案:

没有答案