I have a textbox with content. I just need like,when I select the text and right click, the appropriate ( reference) list should be displayed as pop up based on the selected text.
For example. In the article, there would be "This is referred by (williams, 2012)". If I select Williams and right click , the reference list with the name williams should be listed as popup.
javascript code:
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
alert("You've tried to open context menu"); //here you draw your own menu
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
alert("You've tried to open context menu");
window.event.returnValue = false;
});
}
HTML:
<body>
Lorem ipsum...
</body>
This code is from jsfiddle
Right now, am just with this code only I don't have any idea how to build it to my requirement.When right click with the selected text how to pop up the appropriate list. Pls help!
http://blog.teamtreehouse.com/building-html5-context-menushttp://livepipe.net/control/contextmenu