Results 1 to 2 of 2

Thread: how do you add something to the right click menu of internet explorer?

  1. #1

    Thread Starter
    New Member the unknown's Avatar
    Join Date
    Dec 2001
    Posts
    5

    how do you add something to the right click menu of internet explorer?

    i don't know how
    i would like to know how

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Here you go, just save it as a htm file

    Code:
    <script language="javaScript">
    <!--
    
    ///////////////////////////////////////////////////////////////////////////////
    //
    // change the menuItems array with your options and set the urls to link to
    //  use addMenuItem("Text to show", "Url To Link To"); to make an item
    //  use addMenuItem("Text", Url", "Img To Show"); to make an item with an image
    //  use addMenuItem(); to indicate a separator bar
    //  you can use html tags in the text, eg, <i>, <b> or <u>
    //
    // images used should be 16x16 transparent gifs
    //
    // it may be nessecary to change the menuHeight and menuWidth
    //  menuHeight is the height of the popup menu in pixels
    //  menuWidth is the width of the popup menu in pixels
    //
    // menuDelay is the delay, in thousandths of seconds, before the menu appears
    //  the default is 50 thousandths of a second
    //
    // menuSpeed is used to adjust the speed at which the menu appears
    //  a lower value for menuSpeed makes it faster but disjointed
    //  a higher value for menuSpeed makes it slower but smoother
    //  a value of 1 or less makes the menu appear instantly
    //  the default is 8
    //
    // menuOffet is the horizontal and vertical offset of the menu
    //  is is the distance the menu appears from the mouse pointer
    //  the default is 2 pixels
    ///////////////////////////////////////////////////////////////////////////////
    
     menuItems = new Array();
     menuItemNum = 0;
    
     function addMenuItem(text, url, img){
      if(img) menuItems[menuItemNum] = new Array(text, url, img);
      else if(text) menuItems[menuItemNum] = new Array(text, url);
      else menuItems[menuItemNum] = new Array();
      menuItemNum++;
     }
    
    
     menuWidth = 158;
     menuHeight = 271;
     menuDelay = 50;
     menuSpeed = 8;
     menuOffset = 2;
    
     addMenuItem("<center>IE Context Menu</center>","url.htm");
     addMenuItem();
     addMenuItem("<u>B</u>ack","url.htm");
     addMenuItem("F<u>o</u>rward","url.htm");
     addMenuItem();
     addMenuItem("<u>S</u>ave Background As...","url.htm");
     addMenuItem("Set as <u>W</u>allpaper","url.htm");
     addMenuItem("<u>Z</u>ip File","url.htm");
     addMenuItem("Set as <u>D</u>esktop Item...","url.htm");
     addMenuItem();
     addMenuItem("Create Shor<u>t</u>cut","url.htm");
     addMenuItem("Add to <u>F</u>avorites...","url.htm");
     addMenuItem("<u>V</u>iew Source","url.htm");
     addMenuItem();
     addMenuItem("<u>P</u>roperties","url.htm");
     addMenuItem();
     addMenuItem("<b>B<u>o</u>ld Text</b>","url.htm");
     addMenuItem("<i>Ita<u>l</u>ic Text</i>","url.htm");
    
    
    
    
     ///////////////////////////////////////////////////////////////////////////////
     // do not edit the code below, it is required for the menu to work correctly
     ///////////////////////////////////////////////////////////////////////////////
    
     ///////////////////////////////////////////////////////////////////////////////
     // check for ie5.5
     ///////////////////////////////////////////////////////////////////////////////
    
     if(window.navigator.appName == "Microsoft Internet Explorer" && window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE") + 5, window.navigator.appVersion.indexOf("MSIE") + 8) >= 5.5)
      isIe = 1;
     else
      isIe = 0;
    
    
     ///////////////////////////////////////////////////////////////////////////////
     // create the menu in the form of a table
     // if menu array image exists, create an item with an image
     // if menu array text exists, create an item
     // else create a separator bar
     //
     // create menuPopup as popup object using createPopup(), put menuContent in the body
     ///////////////////////////////////////////////////////////////////////////////
    
     if(isIe){
      menuContent = '<table id="rightMenu" width="0" height="0" cellspacing="0" cellpadding="0" style="font:menu;color:menutext;"><tr height="1"><td style="background:threedlightshadow" colspan="4"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threedlightshadow"></td><td style="background:threedhighlight" colspan="2"></td><td style="background:threedshadow"></td><td style="background:threeddarkshadow"></td></tr><tr height="10"><td style="background:threedlightshadow"></td><td style="background:threedhighlight"></td><td style="background:threedface"><table cellspacing="0" cellpadding="0" nowrap style="font:menu;color:menutext;cursor:default;">';
      for(m=0;m<menuItems.length;m++){
       if(menuItems[m][0] && menuItems[m][2])
        menuContent += '<tr height="17" onMouseOver="this.style.background=\'highlight\';this.style.color=\'highlighttext\';" onMouseOut="this.style.background=\'threedface\';this.style.color=\'menutext\';" onClick="parent.window.location.href=\'' + menuItems[m][1] + '\'"><td style="background:threedface" width="1" nowrap></td><td width="21" nowrap><img src="' + menuItems[m][2] + '"></td><td nowrap>' + menuItems[m][0] + '</td><td width="21" nowrap></td><td style="background:threedface" width="1" nowrap></td></tr>';
       else if(menuItems[m][0])
        menuContent += '<tr height="17" onMouseOver="this.style.background=\'highlight\';this.style.color=\'highlighttext\';" onMouseOut="this.style.background=\'threedface\';this.style.color=\'menutext\';" onClick="parent.window.location.href=\'' + menuItems[m][1] + '\'"><td style="background:threedface" width="1" nowrap></td><td width="21" nowrap></td><td nowrap>' + menuItems[m][0] + '</td><td width="21" nowrap></td><td style="background:threedface" width="1" nowrap></td></tr>';
       else
        menuContent += '<tr><td colspan="5" height="4"></td></tr><tr><td colspan="5"><table cellspacing="0"><tr><td width="2" height="1"></td><td width="0" height="1" style="background:threedshadow"></td><td width="2" height="1"></td></tr><tr><td width="2" height="1"></td><td width="100%" height="1" style="background:threedhighlight"></td><td width="2" height="1"></td></tr></table></td></tr><tr><td colspan="5" height="3"></td></tr>';
      }
      menuContent += '</table></td><td style="background:threedshadow"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threedlightshadow"></td><td style="background:threedhighlight"></td><td style="background:threedface"></td><td style="background:threedshadow"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threedlightshadow"></td><td style="background:threedshadow" colspan="3"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threeddarkshadow" colspan="5"></td></tr></table>';
    
      menuPopup = window.createPopup();
      menuPopup.document.body.innerHTML = menuContent;
     }
    
    
     ///////////////////////////////////////////////////////////////////////////////
     // function:  showMenu()
     // set location of menu (mouse pointer)
     // create menuTimer, a timer for the menu slideIn
     // return false to stop old menu appearing
     ///////////////////////////////////////////////////////////////////////////////
    
     function showMenu(){
      menuXPos = event.clientX + menuOffset;
      menuYPos = event.clientY + menuOffset;
    
      menuXIncrement = menuWidth / menuSpeed;
      menuYIncrement = menuHeight / menuSpeed;
    
      menuTimer = setTimeout("openMenu(0,0)", menuDelay);
    
      return false;
     }
    
    
     ///////////////////////////////////////////////////////////////////////////////
     // function:  openMenu(height, width)
     // use the height and width to slideIn the popupMenu
     // else create an item and attach change loction.href action to it
     ///////////////////////////////////////////////////////////////////////////////
    
     function openMenu(height, width){
      iHeight = height;
      iWidth = width;
    
      menuPopup.show(menuXPos, menuYPos, iWidth, iHeight, document.body);
    
      if(iHeight < menuHeight)
       menuTimer = setTimeout("openMenu(iHeight + menuYIncrement, iWidth + menuXIncrement)", 1);
      else
       clearTimeout(menuTimer);
     }
    
    
     ///////////////////////////////////////////////////////////////////////////////
     // attach the showMenu function to any contextMenu event
     // this means that the menu appears on right click
     // it appears on rclick of both the body and any image or text
     ///////////////////////////////////////////////////////////////////////////////
    
     if(isIe) document.oncontextmenu = showMenu;
    
    
    -->
    </script>
    <h4 align=center>Right click on the blank space to see the context menu</h4>
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width