How to practically configure IE context menu?

I need to add one menu item to the IE context menu. This is similar to the Google context menu "Google Search for xxx" when you right-click on IE.

I did some research and found that overriding IDocHostUIHandler :: ShowContextMenu in IE BHO can customize the IE context menu. An example project can be found in the popup blocker project published in codeproject. It works well and is easy to implement. However, this approach has a problem. The problem is that this contradicts the setting of the context menu of other add-ins on MSDN.

There are several discussions on this topic in the MSDN Internet Explorer Center forum. However, the correct implementation has not been published.

If anyone has experience with this, please share your idea. Thank!

+3
source share
2 answers

See Adding Entries to the Standard Context Menu in MSDN.

For some code examples, download and extract the web accessory for Internet Explorer 5 (the mechanism still works in versions of IE up to and including 8). Take a look at ie5wa.infand *.htmlfor examples of various IE context menu extensions.

, abive COM, , blob script (Javascript, JScript, VBScript ..). script (JScript, VBScript) , , COM, ,

  • HKCU\Software\Microsoft\Internet Explorer\MenuExt\My &Context Menu" registry key ( & ` , )
  • , , script, , , COM- ( IDispatch IIRC, )
  • contexts (0x02 , 0x10 ..), ,
+2

IE, . .

javascript [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]:

  var parentwin = external.menuArguments;
  var doc = parentwin.document;
  var sel = doc.selection;
  var rng = sel.createRange();
  var str = new String(rng.text);

  if(0 < str.length)
  {
    if (str.indexOf("http")!=0)
        window.open("http://"+str, "_blank");
    else 
        window.open(str, "_blank");
  }
0

Source: https://habr.com/ru/post/1740260/


All Articles