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

plz plz help me "how can i face dell varcent round"....? plzzzzzzzz help me friends.....?

0 Answers   DELL,


What is a superheterodyne receiver?

2 Answers  


successful command to make linux system as router in redhat-+

0 Answers  


What is the meaning of int p(char*a);

0 Answers  


Paul the octopus who has been forecasting the outcome of FIFA world cup matches with tremendous accuracy has now been invited to predict ICC world cup matches in 2011. We will assume that the world cup contenders have been divided into 2 groups of 9 teams each. Each team in a group plays the other teams in the group. The top two teams from each group enter the semi finals ( after which the winner is decided by knockout). However, Paul has a soft spot for India and when India plays any team, Paul always backs India. Alas, his predictions on matches involving India are right only 2 out of 3 times. In order to qualify for the semi finals, it is sufficient for India to win 7 of its group matches. What is the probability that India will win the ICC world cup?

1 Answers   TCS,






What is the difference between Huawei 5700 switch and 5300 switch?

1 Answers   Huawei,


PLC Training in chennai ? Best PLC Training center in chennai?

1 Answers  


is it possible to get u.s visa with 55% in b-tech and 15 backlogs

0 Answers  


explain various object oriented programming fetures

0 Answers  


Dear sir 1: i know about IIT & AIEEE prepration which city is best and top 1 position ? 2: Top 10 institute in INDIA for prepration to IIT & AIEEE plz get me detail knowldge? 3: where is better invoirnment availble for IIT & AIEEE entrance exam? 4: What diffrent between KOTA & DELHI institute and enviornment

1 Answers  


what is the difference between C and C++? what is the difference between scanf and gets? what is mean by extern what is the use of it? what will happen if i say delete this> Difference between C structure and C++ structure? What is the difference between overloading and overridding? Explain the need for "virtual Destructor" Can we have "virtual Constructors"? What is the different types of polymorphism> What is virtual functions? How to implement virtual function in "C"? What are the different types of storage classes?

0 Answers  


project plan for bug tracking system?

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)