{"id":324,"date":"2013-08-25T22:18:44","date_gmt":"2013-08-25T14:18:44","guid":{"rendered":"http:\/\/blog.sorayuki.net\/?p=324"},"modified":"2013-09-26T15:09:27","modified_gmt":"2013-09-26T07:09:27","slug":"%e4%bd%bfwebbrowser%e6%8e%a7%e4%bb%b6%e4%bd%bf%e7%94%a8ie10%e6%a0%b8%e5%bf%83","status":"publish","type":"post","link":"https:\/\/blog.sorayuki.net\/?p=324","title":{"rendered":"\u4f7fWebBrowser\u63a7\u4ef6\u4f7f\u7528IE10\u6838\u5fc3"},"content":{"rendered":"<p>\u5728\u7a0b\u5e8f\u4e2d\u8981\u663e\u793a\u4e00\u4e2a\u7f51\u9875\u6216\u8005\u5565\u7684\u7684\u65f6\u5019\uff0cWebBrowser\u63a7\u4ef6\u5f88\u597d\u7528\u3002\u4f46\u662f\u8fd9\u4e1c\u897f\u4f3c\u4e4e\u4e0d\u4f1a\u968f\u7740\u4f60IE\u7684\u5347\u7ea7\u800c\u5347\u7ea7\uff0c\u800c\u662f\u4e00\u76f4\u4f7f\u7528IE6\u6838\u5fc3\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u6bd4\u5982\u4eca\u5929\u7fa4\u91cc\u5728\u4f20\u4e00\u4e2a\u65e0\u804a\u7684\u7f51\u7ad9 <a title=\"http:\/\/orteil.dashnet.org\/experiments\/cookie\/\" href=\"http:\/\/orteil.dashnet.org\/experiments\/cookie\/\">http:\/\/orteil.dashnet.org\/experiments\/cookie\/<\/a> \u7b80\u5355\u8bf4\u5c31\u662f\u4e0d\u505c\u70b9\u9f20\u6807\u3002\u7136\u540e\u6211\u5c31\u8981\u641e\u4e2a\u4f5c\u5f0a\u5668\uff0c\u8fd0\u884c\u811a\u672c\u76f4\u63a5\u53d8\u66f4\u90a3\u4e2aCookie\u6570\u3002\u7b80\u5355\u7684\u529e\u6cd5\u5c31\u662f\u62d6\u4e00\u4e2aWebBrowser\u63a7\u4ef6\uff0c\u7136\u540e\u4f7f\u7528\u8fd9\u6837\u7684\u4ee3\u7801\u4fee\u6539\u6570\u76ee\uff1a<\/p>\n<div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:d7427de1-fc23-4120-b2a3-9d43ecd55e40\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">         <code><\/p>\n<pre>webBrowser1.Navigate(\"javascript:function Hack(a) {Cookies+=a;}Hack(10000);\");\n <\/pre>\n<p><\/code>\n      <\/div>\n<p>\u4f46\u662f\u53d1\u73b0\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662fWebBrowser\u63a7\u4ef6\u6253\u5f00\u7f51\u9875\u7684\u65f6\u5019\u8001\u662f\u62a5\u9519\uff0c\u4f46\u662f\u7528IE\u5f00\u5374\u4e0d\u4f1a\u3002\u6211\u7cfb\u7edf\u91cc\u88c5\u7684\u662fIE10\uff0c\u6211\u89c9\u5f97WebBrowser\u5728\u4f7f\u7528IE6\u5185\u6838\u3002<\/p>\n<p>\u4e0a\u7f51\u641c\u7d22\u5173\u952e\u5b57\u201cWebBrowser C# IE10\u201d\u4ee5\u540e\u51fa\u6765\u4e86<a href=\"http:\/\/stackoverflow.com\/questions\/15829397\/webbrowser-using-ie10-c-sharp-winform\" target=\"_blank\">\u4e00\u4e2aStackOverflow\u7684\u7f51\u9875<\/a>\uff0c\u539f\u6765\u662f\u5728\u6ce8\u518c\u8868\u91cc\u9762\u6dfb\u52a0\u4e00\u4e2a\u952e\u503c\u5c31\u597d\u4e86\u3002<\/p>\n<p><div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:d4da8851-b3a4-4062-9811-942e8253edb6\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">\n        <code><\/p>\n<pre>FEATURE_BROWSER_EMULATION \"myAppName.exe\"=10000 (or 0x02710) and not 1000.\nIn HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION\nand HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION\n\nIt works for me\n <\/pre>\n<p><\/code>\n      <\/div>\n<\/p>\n<p>\u7136\u540e\u6211\u987a\u4fbf\u628a\u5982\u4f55\u5220\u9664\u8fd9\u6837\u5b57\u7b26\u4e32\u503c\u7684\u6ce8\u518c\u8868\u6587\u4ef6\u5185\u5bb9\u8d34\u51fa\u6765\u3002\u7528<\/p>\n<div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:4e5eefc8-5f07-4a2f-9f39-11e6bd62531c\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">\n        <code><\/p>\n<pre>Windows Registry Editor Version 5.00\n\n[-HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION\\HackCookies.exe]\n <\/pre>\n<p><\/code>\n      <\/div>\n<p>\u662f\u4e0d\u884c\u7684\u3002\u8981\u8fd9\u6837\uff1a<\/p>\n<div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:4fa9d8d7-85cd-4930-983b-52c656c74d98\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">\n        <code><\/p>\n<pre>Windows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION]\n\"HackCookies.exe\"=-\n\n <\/pre>\n<p><\/code>\n      <\/div>\n<\/p>\n<p>\u6ce8\u610f\uff1aVS\u91cc\u9762\u8c03\u8bd5\u7684\u8bdd\uff0cEXE\u6587\u4ef6\u540d\u662fHackCookies.vshost.exe\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u7136\u540e\u6ce8\u5165\u811a\u672c\u65b9\u9762\uff0c<a href=\"http:\/\/stackoverflow.com\/questions\/153748\/how-to-inject-javascript-in-webbrowser-control\" target=\"_blank\">\u7f51\u4e0a<\/a>\u627e\u5230\u8fd9\u6837\u7684\u65b9\u6cd5<\/p>\n<p><div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:7e26627d-a299-469b-9375-c487b3ee4352\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">\n        <code><\/p>\n<pre>HtmlDocument doc = browser.Document;\nHtmlElement head = doc.GetElementsByTagName(\"head\")[0];\nHtmlElement s = doc.CreateElement(\"script\");\ns.SetAttribute(\"text\",\"alert('hello');\");\nhead.AppendChild(s);\n\n(tested in .NET 4 \/ Windows Forms App)\n <\/pre>\n<p><\/code>\n      <\/div>\n<\/p>\n<p>\u6216\u8005\u8fd8\u6709\u8fd9\u6837\u7684<\/p>\n<div id=\"scid:887EC618-8FBE-49a5-A908-2339AF2EC720:02b20d72-a50a-4069-8ee9-2cdfba272bff\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">\n        <code><\/p>\n<pre>Here is the easiest way that I found after working on this:\nstring jCode = \"alert(\"Hello\");\"\n\/\/ or any combination of your JavaScript commands\n\/\/ (including function calls, variables... etc)\n\n\/\/ WebBrowser webBrowser1 is what you are using for your web browser\nwebBrowser1.Document.InvokeScript(\"eval\", new object[] { jCode });\n\nWhat global JavaScript function eval(str) does is parses and executes whatever is written in str. Check w3schools ref here.\n <\/pre>\n<p><\/code>\n      <\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7a0b\u5e8f\u4e2d\u8981\u663e\u793a\u4e00\u4e2a\u7f51\u9875\u6216\u8005\u5565\u7684\u7684\u65f6\u5019\uff0cWebBrowser\u63a7\u4ef6\u5f88\u597d\u7528\u3002\u4f46\u662f\u8fd9\u4e1c\u897f\u4f3c\u4e4e\u4e0d\u4f1a\u968f\u7740\u4f60IE\u7684\u5347\u7ea7\u800c\u5347\u7ea7 &hellip; <a href=\"https:\/\/blog.sorayuki.net\/?p=324\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u4f7fWebBrowser\u63a7\u4ef6\u4f7f\u7528IE10\u6838\u5fc3<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,15],"tags":[],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-windows","category-15"],"_links":{"self":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=324"}],"version-history":[{"count":0,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/324\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}