私はこのコードを持っています:
$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