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
<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");
}
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 ? | 14 Yes | 13 No |
Post New Answer View All Answers
write a program for reverse a given string?
What is the difference between CD-R and CD+R?
What are annotations? What are assertions? why they are used why not if-else?? what is normalization? what is QuickSort? what are Avl trees?
What is the difference between operator overloading and function overloading in C when compared with C++?
there are 50 users in a network, one system is virus affected , how to find that virus affected system?
what two ways you can use to ensure that visual basic does not allow uncleared variables?
why does a microprocessor generally hAVE more address lines than data lines?
#include
write a pgm to accept an array of names & name & check whether the name is present in the array. return the count of occurance. use following array as input; {"Dave","Ann","dev","merry"}
what are the differences between malloc() and calloc() in c language?
Can have i call constructor in interface?
I want to prepare for PSU's bt i dont know how many PSU's are open for computer science students and what is the competition level for these. So if anybody knows this please guide me through this.
difference between tcp ip and open system interconnection
how to conrtruct gear make him rotate on its axis
What are the frequently asked technical engineer ques?