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)

Answers were Sorted based on User's Feedback



Write a function that responds to a click anywhere on the page by displaying an alert dialog. Disp..

Answer / 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

Write a function that responds to a click anywhere on the page by displaying an alert dialog. Disp..

Answer / 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

More Engineering AllOther Interview Questions

i want to know details about SBI bank exam and date when to apply and what is the eligibility and the model papers related to it and various post available for Engineering in Information Technology.

0 Answers  


i need to alone print a number no text by using if statement .say some idea

0 Answers  


if your monitor is not started with your cpu, but start when monitor attach to another cpu then where is the problem?

2 Answers  


anybody, Please send me the NIC(scientific officer/programmer) model questions papers to this mail id:imtiyazahamed14@gmail.com

0 Answers  


how can i install windows-xp operating system in single time to 50 computersconnected in a LAN.

0 Answers   Bank Of America,






When a new build comes what is the first step taken by a tester in testing

1 Answers   Sonata,


How to trouble of routing protocol like EIGRP and OSPF

1 Answers   NetMagic,


what is c dot

0 Answers  


why bin folder is not be created in windows os?

1 Answers  


what is buffer solution?

0 Answers   HCL,


Guys! I coplted 10th with 80% and +2 with 64% now am dng c.s.e b.tech...i want to go abroad for higher studies i want to write tofel...plZ GIVE UR SUGGESTIONS!

0 Answers  


when load increase in generator in island mode, why turbine rpm is reduced

0 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16632)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)