{"id":39213,"date":"2004-05-24T07:03:00","date_gmt":"2004-05-24T07:03:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/05\/24\/extending-the-internet-explorer-context-menu\/"},"modified":"2004-05-24T07:03:00","modified_gmt":"2004-05-24T07:03:00","slug":"extending-the-internet-explorer-context-menu","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040524-00\/?p=39213","title":{"rendered":"Extending the Internet Explorer context menu"},"content":{"rendered":"<p>\n<a HREF=\"http:\/\/dotnetjunkies.com\/WebLog\/bsblog\/archive\/2004\/05\/10\/13199.aspx#13203\">\nIn a comment<\/a>,\n<a HREF=\"http:\/\/dotnetjunkies.com\/WebLog\/darrell.norton\/\">\nDarrell Norton<\/a> asked\nfor a &#8220;View in Mozilla&#8221; option for Internet Explorer.\n<\/p>\n<p>\nYou can already do this.\n<\/p>\n<p>\nInternet Explorer&#8217;s\n<a HREF=\"http:\/\/msdn.microsoft.com\/workshop\/browser\/ext\/tutorials\/context.asp\">\ncontext menu extension mechanism<\/a>\nhas been in MSDN for years.\nLet me show you how you can create this extension yourself.\n<\/p>\n<p>\nFirst, create the following registry key:\n<\/p>\n<pre>\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\View in Mozilla]\n@=REG_SZ:\"C:\\some\\path\\to\\ViewInMozilla.htm\"\nContexts=REG_DWORD:1\n<\/pre>\n<p>\nOf course, you need to change C:\\some\\path\\to to an actual path.\n<\/p>\n<p>\nHow did I know to do this?\nBecause steps 1, 2 and 3 in the &#8220;Implementation Steps&#8221; section tell\nme (1)&nbsp;what key to create, (2)&nbsp;what to set the default value to, and\n(3)&nbsp;what to set Contexts to.\nI chose a Context value of 1, which means &#8220;Default&#8221;.\n<\/p>\n<p>\nOkay, now to write the script ViewInMozilla.htm.\nWell, the documentation says that I can access context\nfrom the\n<a HREF=\"http:\/\/msdn.microsoft.com\/workshop\/author\/dhtml\/reference\/properties\/menuarguments.asp\">\nmenuArguments<\/a>\nproperty of the\n<a HREF=\"http:\/\/msdn.microsoft.com\/workshop\/author\/dhtml\/reference\/objects\/external.asp\">\nexternal<\/a> object.\nSo let&#8217;s start with that.\n<\/p>\n<pre>\n&lt;SCRIPT&gt;\nalert(external.menuArguments);\n&lt;\/SCRIPT&gt;\n<\/pre>\n<p>\nOkay, let&#8217;s run this puppy.  Launch IE, right-click on a blank\nspace in the web page, select &#8220;View in Mozilla&#8221;, and you get&#8230;\n<\/p>\n<pre>\n    [object]\n<\/pre>\n<p>\nWoo-hoo!  This is a major accomplishment: Something happened at all.\nDoing things in small steps makes it easy to identify where a problem is.\nIf we had run full steam ahead to completion\nand then it didn&#8217;t work, we wouldn&#8217;t have\nknown whether it was due to a bug in the script, a bad registration, a bad\nfilename&#8230;\n<\/p>\n<p>\nNow that I have the menu arguments, I can use that\nto suck out information about the item that the context menu\napplies to.  Let&#8217;s try this:\n<\/p>\n<pre>\n&lt;SCRIPT&gt;\nalert(external.menuArguments.document.URL);\n&lt;\/SCRIPT&gt;\n<\/pre>\n<p>\nWoo-hoo, now it gives me the URL.  Almost there. All that&#8217;s\nleft to do is to run a program with that URL as the command line\nparameter.\n<\/p>\n<pre>\n&lt;SCRIPT&gt;\nvar shell = new ActiveXObject(\"WScript.Shell\");\nshell.run(\"mozilla \\\"\" + external.menuArguments.document.URL + \"\\\"\");\n&lt;\/SCRIPT&gt;\n<\/pre>\n<p>\nMission accomplished.\n<\/p>\n<p>\nNow you too can create Internet Explorer context menu extensions.\n<\/p>\n<p>\nIn fact, go ahead and do it, since Darrell asked for it:\nCreate an Internet Explorer\ncontext menu extension that operates on anchors and opens the\nlinked-to page in Mozilla.\n<\/p>\n<p>\n(Bonus:\n<a href=\"http:\/\/weblogs.asp.net\/tonyschr\/\">\nTony Schreiner<\/a>\ncooked up\n<a href=\"http:\/\/weblogs.asp.net\/tonyschr\/archive\/2004\/05\/05\/126305.aspx\">\nsomething similar for zooming<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a comment, Darrell Norton asked for a &#8220;View in Mozilla&#8221; option for Internet Explorer. You can already do this. Internet Explorer&#8217;s context menu extension mechanism has been in MSDN for years. Let me show you how you can create this extension yourself. First, create the following registry key: [HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\View in Mozilla] @=REG_SZ:&#8221;C:\\some\\path\\to\\ViewInMozilla.htm&#8221; Contexts=REG_DWORD:1 [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-39213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>In a comment, Darrell Norton asked for a &#8220;View in Mozilla&#8221; option for Internet Explorer. You can already do this. Internet Explorer&#8217;s context menu extension mechanism has been in MSDN for years. Let me show you how you can create this extension yourself. First, create the following registry key: [HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\View in Mozilla] @=REG_SZ:&#8221;C:\\some\\path\\to\\ViewInMozilla.htm&#8221; Contexts=REG_DWORD:1 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/39213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=39213"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/39213\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=39213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=39213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=39213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}