View Single Post
Old 02-08-2013, 10:06 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,196
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Code:
        <script type="text/javascript">
            initMenu();
            MenuObj.style.display = 'none';
            var bx = document.getElementById("box");
            bx.onclick = function( evt )
                {
                    if ( evt == null ) evt = window.event;
                    if ( evt.which == 3 ) { showMenu(); }
                }
            document.documentElement.onclick = hideMenu;
        </script>
BUT...

But the right click only works *WHILE* the drop down is being displayed.

If you try to right click on the <select> before the <option>s are all being displayed, you get the normal page context menu.

Another way to do this would be to use document.documentElement.onclick and check for right click (same as I do there) and *also* check to see if the mouse is within the bounds of the <select>. But that's a pain in the patootie.

Hmmm...might be a tad easier if you surrounded the <select> with a <div> and looked for the mouse in the <div>??
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Users who have thanked Old Pedant for this post:
jason_kelly (02-11-2013)