Make my right click context menus occur only in selected divs

Hi
I want to make some context menus for certain divs in my website page. So the person viewing the site sees a link to a music file and they right click on the link to get more options but instead of the default browser options coming up, a customized list comes up.
This is just an example. The real thing is that I want multiple menus that work in selected divs only. So if you click in most places on the page you get the default context menu but if you click within certain divs you get a different menu.
So far everyone has just given me java script but i can't set html links inside of javascript. Can anyone tell me how to take this script and make it apply to divs instead of the whole document?
<script src="SpryAssets/SpryTooltip.js" type="text/javascript"></script>
    <script type="text/javascript">   
    var contextMenuObj;
    var MSIE = navigator.userAgent.indexOf('MSIE')?true:false;
    var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;   
    var activeContextMenuItem = false;
    function highlightContextMenuItem()
        this.className='contextMenuHighlighted';
    function deHighlightContextMenuItem()
        this.className='';
    function showContextMenu(e)
      contextMenuSource = this;
      if(activeContextMenuItem)activeContextMenuItem.className='';
      if(document.all)e = event;
      var xPos = e.clientX;
      if(xPos + contextMenuObj.offsetWidth > (document.documentElement.offsetWidth-20)){
       xPos = xPos + (document.documentElement.offsetWidth - (xPos + contextMenuObj.offsetWidth)) - 20;
      var yPos = e.clientY;
      if(window.document.body.scrollTop > 0)
          yPos = (window.screen.Height) ? e.clientY + window.document.body.scrollTop -20 : e.clientY -20;
        else if (window.pageYOffset)
          yPos = (window.pageYOffset > 0) ? e.clientY + window.pageYOffset -20 : e.clientY -20;
        else
        { yPos = e.clientY -20; }
      contextMenuObj.style.left = xPos + 'px';
      contextMenuObj.style.top = yPos + 'px';
      contextMenuObj.style.display='block';
      return false;
    function hideContextMenu(e)
        if(document.all) e = event;
        if(e.button==0 && !MSIE){
        }else{
            contextMenuObj.style.display='none';
    function initContextMenu()
        contextMenuObj = document.getElementById('contextMenu');
        contextMenuObj.style.display = 'block';
        var menuItems = contextMenuObj.getElementsByTagName('LI');
        for(var no=0;no<menuItems.length;no++){
            menuItems[no].onmouseover = highlightContextMenuItem;
            menuItems[no].onmouseout = deHighlightContextMenuItem;
            var aTag = menuItems[no].getElementsByTagName('A')[0];
            var img = menuItems[no].getElementsByTagName('IMG')[0];
            if(img){
                var div = document.createElement('DIV');
                div.className = 'imageBox';
                div.appendChild(img);
                if(MSIE && navigatorVersion<6){
                    aTag.style.paddingLeft = '0px';
                var divTxt = document.createElement('DIV');   
                divTxt.className='itemTxt';
                divTxt.innerHTML = aTag.innerHTML;
                aTag.innerHTML = '';
                aTag.appendChild(div);
                aTag.appendChild(divTxt);
                if(MSIE && navigatorVersion<6){
                    div.style.position = 'absolute';
                    div.style.left = '2px';
                    divTxt.style.paddingLeft = '15px';
                if(!document.all){
                    var clearDiv = document.createElement('DIV');
                    clearDiv.style.clear = 'both';
                    aTag.appendChild(clearDiv);       
            }else{
                if(MSIE && navigatorVersion<6){
                    aTag.style.paddingLeft = '15px';
                    aTag.style.width = (aTag.offsetWidth - 30) + 'px';
                }else{
                    aTag.style.paddingLeft = '30px';
                    aTag.style.width = (aTag.offsetWidth - 60) + 'px';
        contextMenuObj.style.display = 'none';       
        document.documentElement.oncontextmenu = showContextMenu;
        document.documentElement.onclick = hideContextMenu;
    </script>
If anyone has an alternative to this that will allow me to apply the following link to one of the items in the  menu I'd like to hear it.
This is the link that I want to use: <a href="Test Audio File.mp3"  download="Test Audio File.mp3">
Thanks
Tohorhilau

Hi, thanks for the quick response!
While trying to find info on how to fix this I looked up some context menu addons for FF and tried one. It didn't work so I uninstalled it and after that everything was back to normal. Odd, but there you have it. I still don't know what went wrong in the first place but for the moment it appears to have cleared up.
Next time though I will try loading into Safe Mode if I find any issues (I forgot there was one!).
Thanks for getting back to me again.
GC

Similar Messages

  • Running Windows 7 Home Premium, Firefox 7.0.1, File/Print won't work (doesn't open print dialog box) nor does control+ p nor will right click context menu ever highlight Print selection option after selecting part of a page, ie no printing whatsoever.

    Previous versions of Firefox all printed. All other browsers, programs - Word, Outlook, IE 9, Live Mail, Excel, Adobe files/documents, etc. print. Have more Add-ons than list of plugins below. Can email jpg. screenshots of all printer settings in about:config. Can't paste them here or below.

    See this: <br />
    http://kb.mozillazine.org/Problems_printing_web_pages

  • Is there any way to prevent the right click context menu from combining Stop/Reload?

    Is there any way (about:config tweak, or something) to prevent the right click context menu from combining Stop/Reload?
    Screenshot of what I'm talking about: http://picsend.net/images/873089StupidReloadSto.png

    I did try the add-on ''Menu Editor'' https://addons.mozilla.org/en-US/firefox/addon/menu-editor/ but even when I separate the navigation reload and stop icons and explicitly have both stop and reload set to be visible on the right click context menu I only get the one option showing.
    Whilst there may be some way of changing this I do not know how to and I do not really see any use case for making such a change. Only one option of the choice: stop or reload, is available at any instance in time, but that is the option you are able to use, the other option is not active and so is not displayed.

  • Right click context menu does not appear only for Java 1.7, AWT TextField

    I have been debugging some issues that an application has been having with Java 1.7 versus older versions. A new problem I have encountered is that the right click context menu does not function in any TextField. It works fine when running/compiling it with any previous version of Java. I have tried coding a simple test with a Frame, Panel and TextField to see if it might be something else in the more complex application that was causing it, but the simple test class has the same problem.
    I have searched for other people having the same issue, but I have not found anything comparable. This seems like a huge change from one version to the next and I am surprised that I am not finding this mentioned anywhere else. Can someone point me to anything that discusses this issue that I am having? Does 1.7 require I implement my own context menu? I realize AWT is old technology, but this is an old, fairly complex application that doesn't use swing, and that is not going to change at this point.
    My simple test:
    import java.awt.*; 
    import java.awt.event.*; 
    import java.util.*; 
    class testF3 extends Panel 
      public static void main(String args[]) 
        Frame f = new Frame(); 
        Panel p = new Panel(); 
        f.setLayout(new BorderLayout()); 
        f.add("North", p); 
        TextField tf1 = new TextField("", 20); 
        p.add(tf1); 
        Dimension medm = f.getSize(); 
        medm.height = 100; 
        medm.width = 200; 
        f.setSize(medm); 
        f.setVisible(true); 

    In the past few days since upgrading to 4.0.4, the entire right-click context menu for links is gone and replaced with one item: "Copy Link" The "Open In New Tab" item, along with some other context items, is no longer there.
    That's actually a problem with your particular installation of Safari, b. I've got all the contextual menu entries with my 4.0.4.
    I helped fix one of these recently here at the forum. Try the procedure from the following post (it got back Tho's missing contextual menu entries):
    http://discussions.apple.com/thread.jspa?messageID=10598385&#10598385

  • T40's Left Shift key makes right click/context menu appear?

    Hello All-
    On my T40, on which I just recently got Windows 7 correctly installed, has a curious behavior:
    When I press the left shift key, it functions the same as if I had pressed the right mouse button.  It functions correctly otherwise, I.E., when using it to capitolize a letter in an email, the letter is capitolized, but as soon as I let go of the shift key, the right click/context menu immediately appears.
    This is exceedingly irritating, as I cannot continue typing until I have navigated out of the menu.
    I have checked to see if the Keyboard Customiser utility is causing this, as I currently have my left Alt key functioning as a Windows button, but it does not appear to be causing this particular issue.
    Does anyone have any idea how I might go about fixing this?
    Thanks in advance,
    G
    Solved!
    Go to Solution.

    Nevermind-
    Had the keyboard customizer set to use the left shfit key as the application key.  Duh.

  • How do I fix the right-click context menu; it has blank entries and shows no selectable options?

    recently I have noticed that my right-click context menu looks like it has no entries. It shows up on a right-click, but the whole menu is blank. On further investigation there are scroll buttons on the top and bottom of the menu and if I hover over the up buttom eventually the normal context commands scroll down from above. I noticed this first a few days ago, shortly after the download of 3.6.13. Today I also noticed that some of my menu bars were showing a similar issue with blank entries in the menus. In one case the menu also didn't register where the mouse was, highlighting a command several steps further up.
    Is this something to do with the new Mozilla or something else? I only run a couple of addons, Ad Block Plus and Tab Mix Plus. Can try to capture a screen shot of the issue, but difficult since the menu dissapears when I try to do a screen grab!
    All help is much appreciated.

    Hi, thanks for the quick response!
    While trying to find info on how to fix this I looked up some context menu addons for FF and tried one. It didn't work so I uninstalled it and after that everything was back to normal. Odd, but there you have it. I still don't know what went wrong in the first place but for the moment it appears to have cleared up.
    Next time though I will try loading into Safe Mode if I find any issues (I forgot there was one!).
    Thanks for getting back to me again.
    GC

  • Update for RDP 8.1 Windows 7 SP1 changed explorer right click context menu

    I have a 4 pcs and 3 nas drive on my network.  previous to the update I could view my pcs and nas drives in explorers right pane left click one and access the folders on it.  since the update I can no longer do this because "remotedesktopconnection"
    has been added as the default (previously it was "open") to the right click context menu.  can someone help me change this back so when I right click a network computer icon in explorer I only see:
    open                                                                   
    AND NOT                              remotedesktop
    open in a new window                                                                                       open
    create shortcut                                                                                                 open
    in a new window
                                                                                                                           create
    shortcut
    the exact update that makes the change is: kb2592687

    Hi
    Theoretically it could be done by modify registry. For example you could
    modify right click menu on .exe file by changing values under
    HKEY_CLASSES_ROOT\exefile\shellex\
    However there are some problems that I cannot define that what kind of “file”
    the network computer is.
    And I found no article specific to this.
    If you really need to restore your context menu and also need this update, I
    suggest you uninstall this update first. Then back up your registry, install it
    again. This time using process monitor you could record all registry modifications during
    this update installation. It might take lots of work.
    I tried to do that for you, unfortunately this update has been deployed in our environment which cannot be uninstalled from update history.
    For more information about process monitor
    https://technet.microsoft.com/en-us/library/bb896645.aspx?f=255&MSPPError=-2147217396
    Regards
    D. Wu
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • "Save link as" in Right-click Context menu is not working properly.

    Firefox 17: In a Google search, when I right click on a .pdf link, the popup window automatically gives a "url" filename and "Firefox Document" as filetype. Previously, the filename would be whatever it was on the website (ie. "filename.pdf") and the filetype would be "Adobe Acrobat Document".
    I know this problem has less to do with Firefox and more to do with JavaScript, because the problem disappears if you disable JavaScript (Tools -- Options -- Content -- uncheck "Enable JavaScript"). What's happening is that JavaScript is somehow altering the link from a purely .pdf link to something else -- perhaps encasing the link inside a set of commands, and the computer is trying to save the command string instead of recognizing the link for what it is. When JavaScript is disabled in Google searches, the highlighted "[PDF]" link no longer appears in front of the link itself, and the "Save link as" function on the right-click works properly.
    Any JavaScript junkies want to try their hand at creating a workaround? One that ensures that the reference created by the right-click context menu matches exactly what the filename is for the website?

    The problem is that Google has an onmousedown attribute added to the links that modify a link if you click or right-click a result link to make the link point to a safe browsing check on the Google server.<br />
    You can see that if you hover a link and you will notice that after you have (right) click a link the the URL changes to www.google.com/url?xxxxx.
    You can use this bookmarklet to remove the onmousedown attributes.
    <pre><nowiki>javascript:(function(){var e=document.querySelectorAll('*[id="search"] a[onmousedown]'),E,i;for(i=0;E=e[i];i++){E.removeAttribute('onmousedown')}})()</nowiki></pre>

  • Is it possible to add a button to the right-click context menu for a user in Outlook 2010 using VBA?

    I've tried many things and read up quite a bit but I cannot figure this out.
    I cannot create an add-in so I have to use VBA.
    I want to add a a button to the right-click context menu when I right-click on a user. Is this possible?

    Hello,
    Yes, it is possible to customize the context menu in Outlook. See
    Customizing Context Menus in Office 2010 for more information.
    But VBA doesn't allow to customize the Fluent UI in Outlook, you need to develop an add-in instead.

  • Reader 9.1.3 Right click context menu

    Good Morning,
    We have deployed the Acrobat Reader 9.1.3 MSP Patch on our network to upgrade to the latest version.  However, after the upgrade we are missing some functionality.  In previous versions we were able to right click on a PDF(s) and have the option to "Print".  With the new version those context menus seem to be missing.  Was this a change done by the product?  If so, anyone know why? And if not, does anyone know what I can do about re-adding this functionality?
    Thank you for your time on this matter,

    I put the following into a .reg file and this seems to work. Anything you see that could be wrong?  It does bring back the "Print" option under the right click context menu.
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\.pdf]
    @="AcroExch.Document"
    "Content Type"="application/pdf"
    [HKEY_CLASSES_ROOT\.pdf\OpenWithList]
    @=""
    [HKEY_CLASSES_ROOT\.pdf\OpenWithList\AcroRd32.exe]
    @=""
    [HKEY_CLASSES_ROOT\.pdf\PersistentHandler]
    @="{F6594A6D-D57F-4EFD-B2C3-DCD9779E382E}"
    [HKEY_CLASSES_ROOT\.pdf\ShellEx]
    [HKEY_CLASSES_ROOT\.pdf\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
    @="{49400A7C-81A8-4F52-8CCE-D54739EE87EC}"
    [HKEY_CLASSES_ROOT\AcroExch.Document]
    "BrowseInPlace"="1"
    "EditFlags"=hex:00,00,01,00
    @="Adobe Acrobat Document"
    [HKEY_CLASSES_ROOT\AcroExch.Document\CLSID]
    @="{B801CA65-A1FC-11D0-85AD-444553540000}"
    [HKEY_CLASSES_ROOT\AcroExch.Document\CurVer]
    @="AcroExch.Document.7"
    [HKEY_CLASSES_ROOT\AcroExch.Document\Shell]
    [HKEY_CLASSES_ROOT\AcroExch.Document\Shell\Open]
    [HKEY_CLASSES_ROOT\AcroExch.Document\Shell\Open\Command]
    @="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" \"%1\""

  • Disable Right Click Context Menu in XP "OPEN WITH ADOBE READER 8"

    How can I eliminate the right click context menu "OPEN WITH ADOBE READER 8" in Windows XP?
    I have general familiarity with removing context menus. I see no option for this one in msconfig, or various context menu editors. I am unable to find a setting in Adobe Reader 8. If you know where the setting is, or have solved this problem, please let me know.
    Thanks,
    Joey

    That would be the device Metadata from the print driver vendor. It's part of the Device Stage feature mainly for client OS.
    Here is some MSDN documentation on the feature.
    http://windows.microsoft.com/en-us/windows7/products/features/device-management
    If this is a print server, use the tools include by the print team if you are performing any management on the server.
    Printmanagement.msc
    The Devices UI is really about devices it's not designed for print management, the spooler team had minimal input on the UI design.
    Alan Morris formerly with Windows Printing Team

  • PowerPoint 2010: deactivate/disable right click context menu

    Hi,
    I am looking for a way to deactivate/disable the right click context menu in PowerPoint 2010/365.
    For the editing font menu it works with the registry entry
    Go to: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\Toolbars\PowerPoint Create a Dword AllowMenuFloaties and set the value to zero. Set to 1 to enable again.
    NOTE This will kill ALL floatie Menus not just the one you mention.
    Does anybody know, how it works for the main right click context menu?

    Hi,
    Hi,
    We can custom the existing right-click context menu in PowerPoint 2010 via VBA.
    A similar issue is addressed here, we can learn from this experience  :
    http://social.msdn.microsoft.com/Forums/en-US/f8c7ee04-2a08-4300-9a73-48ccf084723d/how-to-remove-munu-item-from-popup-menu?forum=worddev
    http://social.msdn.microsoft.com/Forums/office/en-US/c1eb22ba-6ca8-4c21-8100-62185355aa53/customize-rightclick-context-menu-in-powerpoint-2010?forum=officegeneral
    There is an example of Customizing Context Menus in All Versions of Microsoft Excel
    http://msdn.microsoft.com/en-us/library/gg469862(v=office.14).aspx
    If you need detail help, please post it in MSDN forum.
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

  • The Right click context menu, and menu butons are all yellow?

    The right click context menu, and the Drop down menus for the tool bar, all have Yellow Text.
    Everything else is working normally, and the Yellow text is un related to windows itself, as Windows still has the standard coloring for the menus and Right click context. im stumped.
    Adblock Plus 2.0.3
    Easy YouTube Video Downloader 5.9
    EPUB Reader 1.4.1.1
    FoxTab 1.4.4
    Ghostery 2.7.2
    IMVU Toolbar 3.10.0.1
    .Net Framework
    Personas 1.6.2 [have had same persona for ages so its not that]
    Roomy Bookmarks 1.3.3
    Smoothwheel 0.45.6.20100202.1
    Tab scope 1.1.4
    Turn off the lights 2.0.0.71
    Yontoo Layers 1.20.00
    i have latest version of firefox. 11
    no virus detected with Malwarbytes, or Avast.
    setting check through windows shows no carry over from a botched windows theme setting.
    its cosmetic issue mostly, not harmful.

    Hmmm, that shouldn't happen. It's difficult to change the text colors in the interface without installing a theme or an add-on that lets you tweak the menus.
    Can you try switching between the default theme and your current theme?
    Do any of those extensions let you change display settings?

  • Right-Click context menu is gone

    Using Windows 7, Safari 4.0.4. I noticed recently that when I right-click on a link, I saw the link context menu and I used to be able to select "Open in new tab" This was great to use the mouse only to navigate, open new tabs, and surf around...using just the mouse.
    In the past few days since upgrading to 4.0.4, the entire right-click context menu for links is gone and replaced with one item: "Copy Link" The "Open In New Tab" item, along with some other context items, is no longer there.
    To be honest, this is pretty useless. If I'm only using the mouse, then this means that I have to:
    1. Right Click on a link, select Copy Link
    2. Right click in the tab bar and select "New Tab"
    3. Click in the address bar of the new tab to select the field
    4. Right-click in the address bar and select paste
    5. And now I'm still having to use the keyboard to submit the address as there is no "Go" button for the address bar.
    I know I can just Ctrl + Click a link to open in a new tab, but that requires the keyboard and the mouse.
    I'm all for simple interfaces, but why did you take away the link's right-click context menu? It made surfing and opening tabs so easy using just the mouse.

    In the past few days since upgrading to 4.0.4, the entire right-click context menu for links is gone and replaced with one item: "Copy Link" The "Open In New Tab" item, along with some other context items, is no longer there.
    That's actually a problem with your particular installation of Safari, b. I've got all the contextual menu entries with my 4.0.4.
    I helped fix one of these recently here at the forum. Try the procedure from the following post (it got back Tho's missing contextual menu entries):
    http://discussions.apple.com/thread.jspa?messageID=10598385&#10598385

  • Satellite M100 - Right click context menu kepps popping up

    The right click context menu keeps popping up in my Toshiba Satelite M100 thereby making it so hard to type.
    I disabled my touch pad and used a mouse but still the menu keeps popping up. What should I do? How do I know whether my touchpad driver is installed correctly? Also how to reinstall it?
    Please give step by step instruction because when I tried to install, I get the message error in installing ikernel.exe...
    Please help

    Hi,
    I know I sound stupid but I have some questions regarding uninstalling the existing version. I have Toshiba touchpad driver and toshiba touchpad ON/Off utility.
    Should uninstall both? Also i disabled the touchpad using the the ON/OFF utility and used a mouse but still the menu kept popping up.
    This problem occurs most of the time. At times,everything works fine for a few hours and then the problem starts. I scan my computer for viruses once in a week and updates my antivirus daily. Also I had my computer formatted after this problem started. Still this prob occurs.
    Please help.

Maybe you are looking for

  • Disabling clusters of an array of clusters

    I've been using array of clusters in some VIs but I have two problems when working with odd number of elements. The attached VI shows the problems that I have. The VI will generate as many random numbers as specified in the "N of elements" control, a

  • Wrong GROUP_ACCOUNT_NUM values

    Hello everybody: I´d already defined the values for the group account number in the file_group_acct_codes_ora.csv and the values are getting right to the OBIEE Analytic Warehouse table W_GL_ACCOUNT_D. in the Cash flow dashboard located in Financials

  • What is "PDF/A" Mode?

    Greetings, When I open a particular PDF, a blue bar comes up saying "You are viewing this document in PDF/A mode." What is "PDF/A" mode? I'm using Adobe Reader 9.3.1 on Windows 7 Home Premium. Thanks, Shane.

  • Why does the word iCloud appear in my contacts title?

    why does the word "icloud" appear in the title bar (next to all contacts arrow and edit button)?

  • Converting cassette to dvd...

    Hi I am wanting to convert my video recordings off the cassette to a dvd. I have been informed that they get downloaded as AVI files and VOB files. Which is easier to use on the mac, as I would like then to edit the downloaded family movies off the d