I want to send a mouse event and a variable to a JS function from within my html code, I can send the event fine but the problem is sending the event AND a variable. I have included a stripped down version of what I am trying to do. The browser is Chrome. Can anyone offer some advice please?
<script language="JavaScript">
function mouseDown(e,w) {
var ctrlPressed=0;
var evt = navigator.appName=="Netscape" ? e:event;
ctrlPressed =evt.ctrlKey;
self.status="" +"ctrlKey=" +ctrlPressed
if (ctrlPressed)
alert ("Mouse clicked with Ctrl/n and the variable is " + w )
return true;
}
</script>
<body>
<table border = "1" >
<tr>
<td onmousedown="mouseDown(e,\"variable\")"> Link 1 </td>
<td> Link 2 </td>
</tr>
</table>
</body>
Don’t use browser detection. Check whether an object exists instead.
Since the event is passed as the 1st argument, you could try
(I have only tested this on Safari, not guarantee to work on other browsers.)