Write a function that responds to a click anywhere on the
page by displaying an alert dialog. Display the event name
if the user held Shift during the mouse click. Display the
element name that triggered the event if the user held Ctrl
during the mouse click. (Answer in Java Language)
Answer Posted / anil yadav
<html>
<head>
<title>Mouse Events Example</title>
<script type="text/javascript">
function handleEvent(oEvent) {
var oTextbox = document.getElementById("txt1");
oTextbox.value += "\n button down is " +
oEvent.button;
var arrKeys = [];
if (oEvent.ctrlKey)
{
arrKeys.push("Ctrl");
}
if (oEvent.shiftKey)
{
arrKeys.push("Shift");
}
oTextbox.value += "\n keys down are " + arrKeys;
}
</script>
</head>
<body>
<P>Use your mouse to click and double click the red
square.</p>
<div style="width: 100px; height: 100px; background-color:
red"
onclick="handleEvent(event)"
id="div1"></div>
<P><textarea id="txt1" rows="15" cols="50"></textarea></p>
</body>
</html>
| Is This Answer Correct ? | 5 Yes | 7 No |
Post New Answer View All Answers
What is Symbian.?
what is the number of water, sand and cement required for moulding brick?
why u r shifting from engineering to other field ?
Show the forces acting on a ladder
what is your experience with computer-aided design software.
wats the difference between RS latch using NAND n NOR gate? which is to be preffered?
WHAT IS DIFFERENT BETWEEN YOU AND OTHER APPLICANT TO GIVE YOU THE JOB
what is the use of fact tables in your banking project doveleped with teradata?
Hi All... PLease send me if anyone have "Information Security Officer" Aptitude papers. Please Mail me at mannusanghi@gmail.com
what are the various technique used for inter process communication?
Difference between software process model and software process.?
why do you want to join tcs
what are the areas of improvement required in yourself to achieve your career goals? Describe what you are doing/plan to do to address the areas of improvement
what is difference betweeen operator overloading & operator overriding?
1)what to do in emergency situation of having total blackout (on a ship) 2)what to do in emergency situation of flooding in the engine room 3)under what conditions would engine room bilges be pumped overboard? 4)why is high pressure required for the injection of fuel into the cylinder of diesel engine. 5)why is doubled walled pipes employed for high pressure fuel lines? 6)reasons for overheating of main engine 7)how to detect choked fuel valve,leaky piston rings and their remedies during operation in diesel engine? 8)effects of insufficient or excessive cylinder lubrication? 9)causes of a diesel engine piston overheating.