faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 11 people (55%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I create context menu when I right click on an object ? (Exactly like computer Desktop)

Apr 8th, 2008 18:06
ha mo, Abolfazl Shirazi, Abolfazl Shirazi


Abolfazl Shirazi :
Well I asked this question one year ago but nobody can answer it until 
now.
Recently I could find a solution below (Using ActiveX Object) :
<!-- Begin -->
<html>
<head>
<script language="JavaScript"><!--
menuon=false;
function contextmenu(e) {
    if (event.button == 2) {
      menuon=true;
      popmenu.RemoveAllItems();
      popmenu.AddItem("He is a good javascript developer !","Abolfazl 
Shirazi","","");
      popmenu.AddItem("Really nice and cool. I like 
it !","Javascript","","");
      popmenu.AddItem("A good helpful site for 
everybody.","FAQ.com","","");
      popmenu.Popup (event.x,event.y);
    }
}
document.onmousedown = contextmenu;
//-->
</script>
<script language="javascript" for="popmenu" event="onclick(e)">
alert(e)
</script>
</head>
<body>
<h1>Right Click On The Page To See The ContextMenu !</h1>
<object id="popmenu" name="popmenu" width=110 height=110 
classid="CLSID:F5131C24-E56D-11CF-B78A-444553540000"></object>
</body>
</html>
<!-- End -->
I hope that the next time I achieve my answer sooner !!!
Enjoy It Friends !!!
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com