filmov
tv
JavaScript to detect which mouse button is clicked

Показать описание
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
JavaScript to detect which mouse button is clicked
In this video, we will discuss how to use JavaScript and detect which mouse button is clicked.
Left Button 1
Middle Button 4
Right Button 2
Left Button 1
Middle Button 2
Right Button 3
Depending on the browser used, the following code returns left, middle and right click codes.
[input type="button" value="Click Me" onmouseup="getMouseClickCode(event)" /]
[input type="button" value="Clear" onclick="clearText()" /]
[br /]
[br /]
[textarea id="txtArea" rows="3" cols="10"][/textarea]
[script type="text/javascript"]
function clearText()
{
}
function getMouseClickCode(event)
{
{
}
else
{
}
}
function disableRightClick(event)
{
{
}
else
{
}
}
[/script]
The following JavaScript code detects which mouse button is clicked. It works in all versions of IE and most other W3C complaint browsers.
[script type="text/javascript"]
function whichMouseButtonClicked(event)
{
var whichButton;
{
{
case 1:
whichButton = "Left Button Clicked";
break;
case 2:
whichButton = "Middle Button Clicked";
break;
case 3:
whichButton = "Right Button Clicked";
break;
default:
whichButton = "Invalid Button Clicked";
break;
}
}
else
{
{
case 1:
whichButton = "Left Button Clicked";
break;
case 4:
whichButton = "Middle Button Clicked";
break;
case 2:
whichButton = "Right Button Clicked";
break;
default:
whichButton = "Invalid Button Clicked";
break;
}
}
alert(whichButton);
}
function disableRightClick(event)
{
{
}
else
{
}
}
[/script]
[button onmouseup="whichMouseButtonClicked(event)"]Click Me[/button]
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
JavaScript to detect which mouse button is clicked
In this video, we will discuss how to use JavaScript and detect which mouse button is clicked.
Left Button 1
Middle Button 4
Right Button 2
Left Button 1
Middle Button 2
Right Button 3
Depending on the browser used, the following code returns left, middle and right click codes.
[input type="button" value="Click Me" onmouseup="getMouseClickCode(event)" /]
[input type="button" value="Clear" onclick="clearText()" /]
[br /]
[br /]
[textarea id="txtArea" rows="3" cols="10"][/textarea]
[script type="text/javascript"]
function clearText()
{
}
function getMouseClickCode(event)
{
{
}
else
{
}
}
function disableRightClick(event)
{
{
}
else
{
}
}
[/script]
The following JavaScript code detects which mouse button is clicked. It works in all versions of IE and most other W3C complaint browsers.
[script type="text/javascript"]
function whichMouseButtonClicked(event)
{
var whichButton;
{
{
case 1:
whichButton = "Left Button Clicked";
break;
case 2:
whichButton = "Middle Button Clicked";
break;
case 3:
whichButton = "Right Button Clicked";
break;
default:
whichButton = "Invalid Button Clicked";
break;
}
}
else
{
{
case 1:
whichButton = "Left Button Clicked";
break;
case 4:
whichButton = "Middle Button Clicked";
break;
case 2:
whichButton = "Right Button Clicked";
break;
default:
whichButton = "Invalid Button Clicked";
break;
}
}
alert(whichButton);
}
function disableRightClick(event)
{
{
}
else
{
}
}
[/script]
[button onmouseup="whichMouseButtonClicked(event)"]Click Me[/button]
Комментарии