javascript - How to create a Right Click customized menu on li item in HTML -
my requirement want open right click customized menu on particular li item. got js file
http://lablogic.net/index.php#scripts/contextmenu/right-click-menu.php
url in js file right click works on whole page want work li or tags. when users right click on particular li or tag @ time right click menu opens , if user clicks anywhere else hides , open normal right click menu.
please me out .....
for reference.. http://www.dropbox.com or http://skydrive.live.com etc....
for starters, don't know effect achieve, i'll asume it's menu in skydrive when click on files , directories.
there lot of solutions this, can stick yours found code. first things first - need decode it. can use online beutyfiers one: http://jsbeautifier.org/
i've copied code of file contextmenu_o.js
, got code:
var mouse_x = 0; var mouse_y = 0; var mouse_left = false; var mouse_right = false; if (document.addeventlistener != undefined) document.addeventlistener('mousemove', mousemove, true); else if (document.layers) document.captureevents(event.mousedown | event.mousemove | event.mouseup); document.onmousemove = mousemove; document.oncontextmenu = rightmousedown; document.onmousedown = mousedown; document.onmouseup = mouseup; function mousemove(a) { mouse_x = document.all ? event.clientx + document.body.scrollleft : document.layers ? a.x + window.pagexoffset : a.clientx + window.pagexoffset; mouse_y = document.all ? event.clienty + document.body.scrolltop : document.layers ? a.y + window.pageyoffset : a.clienty + window.pageyoffset } function rightmousedown() { mouse_right = true; return false } function init(a, w) { var b = document.createelement("div"); b.id = "contextmenu"; if (!w) var w = 120; b.style.width = w + "px"; var c = '<div style="position:relative;left:10px;top:-4px;">'; c += a; c += ' <a href="http://lablogic.net/scripts/contextmenu/right-click-menu.php" target="_top" title="javascript contextmenu" alt="free javascript menu"><font color="#565656" size="-2">get it...</font></a>'; c += '</div>'; b.innerhtml = c; b.style.position = "absolute"; b.style.left = "0px"; b.style.top = "0px"; b.style.visibility = "hidden"; b.style.overflow = "hidden"; b.style.padding = "4px"; b.style.backgroundcolor = "#ffffff"; b.style.border = "1px solid #6a6868"; document.body.appendchild(b); delete b } function mouseup(e) { if (e.which == 1) document.getelementbyid("contextmenu").style.visibility = "hidden"; else if (e.which == 3) mouse_right = false } function mousedown(e) { if (e.which == 3) { mouse_right = true; document.getelementbyid("contextmenu").style.left = mouse_x + "px"; document.getelementbyid("contextmenu").style.top = mouse_y + "px"; document.getelementbyid("contextmenu").style.visibility = "visible" } }
this isn't universal code out there , need changes. i'm making changes visible here, on jsfiddle, overwrite document div of choice i'm giving event listeners.
Comments
Post a Comment