WebBrowser檢視版本
阿新 • • 發佈:2019-01-09
最近為了抓取淘寶的成交資料,用C#的WebBrowser控制元件開發了一個簡單的程式. 發現WebBrowser控制元件預設使用的版本是IE7的相容模式.而淘寶的寶貝詳細頁居然對IE7的支援不是很好. 成交記錄無法顯示,而我本機安裝的是IE10,那麼有沒有辦法使我的WebBrowser控制元件的使用的IE版本高點呢? 查詢到了MSDN的一篇文章,上面有詳細的說明,簡單翻譯如下:
1,開啟登錄檔
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER) SOFTWARE Microsoft Internet Explorer Main FeatureControl FEATURE_BROWSER_EMULATION contoso.exe= (DWORD) 00000000
其中的"contoso.exe"為您的程式名字.即嵌入了WebBrowser控制元件的可執行程式的名字.
後面的數值"00000000"代表WebBrowser控制元件使用的IE的版本,值對應的IE版本如下圖:
如果您使用的是64位的作業系統,而你的程式是32位的,那麼你則要在以下注冊表中更改該值.
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER) SOFTWARE Wow6432Note Microsoft Internet Explorer Main FeatureControl FEATURE_BROWSER_EMULATION contoso.exe = (DWORD) 00000000
360瀏覽器,傲遊瀏覽器,淘寶瀏覽器等都可以用這種方式來操作.
注意: 我使用VS2010編譯的時候,如果是Debug模式,那麼我在登錄檔中更改的內容無效;如果使用了Release模式,則登錄檔的內容立即生效!
2017-07-19補充IE11的使用方法
- 11001 (0x2EDF) Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive
- 11000 (0x2AF8) :Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode
- 10000 (0x2710) :Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
- 10001 (0x2AF7) :Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
- 9999 (0x270F) :Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
- 9000 (0x2328) :Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
- 8888 (0x22B8) :Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
- 8000 (0x1F40) :Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
- 7000 (0x1B58) :Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.