0

我有这个代码:

$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

4

0 回答 0