• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿(mǎn)街逛

            嚴(yán)以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            WebBrowser與IE的關(guān)系,如何設(shè)置WebBrowser工作在IE9模式下?

            轉(zhuǎn)載自:http://www.cnblogs.com/liuzhendong/archive/2012/03/21/2410107.html

            一.問(wèn)題的提出


            偶然發(fā)現(xiàn),Winform里的WebBrowser和IE實(shí)際安裝的版本似乎并不同步,很有趣!

             

            下面有張圖,里面一個(gè)窗口是用IE9打開(kāi)某網(wǎng)站,另一個(gè)窗口是用Winform+WebBrowser打開(kāi)同樣的網(wǎng)站,有意思的事情出現(xiàn)了。

             

            在IE9窗口中,這個(gè)網(wǎng)站左邊菜單樹(shù)無(wú)法顯示,原因是IE9使用的技術(shù)較新,而網(wǎng)站使用的技術(shù)較舊,未能及時(shí)同步更新到支持IE9所致。該如何辦呢?

            微軟在IE9中提供一個(gè)兼容性視圖功能,只要一點(diǎn)擊兼容性視圖就可以兼容舊版本瀏覽器的網(wǎng)站。
             


            引用MSDN “To overcome potential compatibility issues, Internet Explorer supports a feature called Compatibility View that allows users to display troublesome pages in IE7 mode. “ URL: http://msdn.microsoft.com/en-us/library/dd567845(v=VS.85).aspx

            也就是說(shuō),這個(gè)兼容模式就是IE7的模式。

             

            又查了些ms資料,發(fā)現(xiàn)這個(gè)兼容性視圖在IE8時(shí)首次引入,在IE9,IE10中都將繼續(xù)支持。

             

            再翻回來(lái)看Winform+WebBrowser這個(gè)窗口,它打開(kāi)同樣的網(wǎng)站卻能顯示左邊菜單樹(shù),這樣看來(lái),似乎WebBrowser不用設(shè)置就默認(rèn)自動(dòng)打開(kāi)了兼容性視圖模式。

             

            現(xiàn)在就去仔細(xì)查一下權(quán)威資料,核實(shí)一下兩個(gè)問(wèn)題:
            1.Webbrowser與IE到底是什么關(guān)系?是否確實(shí)用ie內(nèi)核, 是否本質(zhì)上和360安全瀏覽器,傲游瀏覽器和騰訊TT等IE內(nèi)核瀏覽器相同。
            2.Webbrowser是否使用兼容瀏覽模式,以及這個(gè)模式是否能改?

             

            二.查詢(xún)結(jié)果

            1.webbrowser調(diào)用的就是本機(jī)IE9,并且webbrowser默認(rèn)就是運(yùn)行在IE7 mode下,除非你改變它.

            發(fā)現(xiàn)一個(gè)msdn的帖子,明確表示webbrowser調(diào)用的就是本機(jī)IE9,并且webbrowser默認(rèn)就是運(yùn)行在IE7 mode下,除非你改變它。
            How to make c# WebBrowser equivalent to IE browser  
            http://social.msdn.microsoft.com/Forums/en/winforms/thread/2ed65b9d-c601-4ca8-bde1-64584fc87515

            摘幾句:
            Wow first post with such bold claim without any source backing up. You probably should read the IE SDK (the manual you need to read if you want to use the webbrowser control) or dig through the IE programming forums (that's the place others often go when they are stuck on IE programming) if you want to use the webbrowser control.

            Webbrowser is a wrapper around IE APIs. There is no such thing as multiple versions of IE coexisting on the same computer. You will always get the one and only version of IE installed on the computer from webbrowser control.

            There are many, many documented setting differences between default IE and webbrowser. Basically you don't have to opt out new features in webbrowser that may break your app (the Visual Studio team learned a hard lesson here, when IE8 breaks Visual Studio's wizards) , you have to write code to opt in, unless the improvement is security related. That means the webbrowser will run in IE7 mode unless you change the mode in feature control.

            Note some web site declare their requirement of IE7 or IE8 mode. It may not be wise to force the IE9 mode. 

             

            2.微軟新聞組的一個(gè)帖子,Webbrowser Control without IE,里面明確提到,不裝IE,無(wú)法用webbrowser.
            http://groups.google.com/group/microsoft.public.vb.controls/browse_thread/thread/7575bd25e0730ded/aa40f3dfc799407d?lnk=gst&q=WebBrowser+ie#aa40f3dfc799407d

            IE must be installed on the machine for you to use Webbrowser Control.

            Internet Explorer MUST be installed to use the WebBrowser control.  There are simply no ifs, ands, or buts about it.  How can you expect to use IE functionality if IE is not installed?

             

            3.如何設(shè)置WebBrowser在IE9 mode下工作呢?
            答曰:需要修改注冊(cè)表,具體看下面4,5,6,尤其6最全面,可以光看6。

             

            4.WPF webbrowser control using IE7 instead of IE9
            http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/4431908e-1869-4435-bcea-a3ec0820edfb

            摘抄幾句:
            How do I make it so the WPF WebBrowser control will use IE9 as the browser engine instead of IE7?
            I have some HTML that is rendering differently in the WebBrowser control than in the IE9 browser. When I run the following javascript in the WebBrowser, the result is "7". as in IE7.

            I found an article by Rick Strahl that describes registry settings that will get the WebBrowser to use IE9. But I would like to avoid that. And I am interested to know how IE7 comes about being used.http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version
            回答:You want to avoid the only documented way to set document compatibility mode for webbrowser hosts? Why?

             

            5.WebBrowser and CSS3 ?
            http://social.msdn.microsoft.com/Forums/en-AU/winforms/thread/1b656af7-bda9-47d9-8f9a-1d886d3688ca
            Web browser control by default runs in compatibility mode unless you set the feature browser emulation registry key. The fact that IE9 is able to render CSS3 correctly and browser control is not seems to suggest browser control is not running in IE9 standards mode.

            You'll need to set Browser emulation feature key (FEATURE_BROWSER_EMULATION) described at this link http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx

            You can use 9000 value, unless you want to force IE 9 standards mode for all pages. In case of later, you need to use 9999.

            hklm

            If hklm and 64bit machine used, you need to check is Wow6432Node needs to be changed.

            And finally you need to add process name hosting browser control as value name in the registry key.

            Windows Registry Editor Version 5.00

            [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
            "prevhost.exe"=dword:00001f40
            "sllauncher.exe"=dword:00001f40
            "WindowsFormsApplication1.exe"=dword:0000270f

             

            6.Web Browser Control – Specifying the IE Version 
            http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version

            I use the Internet Explorer Web Browser Control in a lot of my applications to display document type layout. HTML happens to be one of the most common document formats and displaying data in this format – even in desktop applications, is often way easier than using normal desktop technologies.

            One issue the Web Browser Control has that it’s perpetually stuck in IE 7 rendering mode by default. Even though IE 8 and now 9 have significantly upgraded the IE rendering engine to be more CSS and HTML compliant by default the Web Browser control will have none of it. IE 9 in particular – with its much improved CSS support and basic HTML 5 support is a big improvement and even though the IE control uses some of IE’s internal rendering technology it’s still stuck in the old IE 7 rendering by default.

            This applies whether you’re using the Web Browser control in a WPF application, a WinForms app, a FoxPro or VB classic application using the ActiveX control. Behind the scenes all these UI platforms use the COM interfaces and so you’re stuck by those same rules.

            Feature Delegation via Registry Hacks
            Fortunately starting with Internet Explore 8 and later there’s a fix for this problem via a registry setting. You can specify a registry key to specify which rendering mode and version of IE should be used by that application. These are not global mind you – they have to be enabled for each application individually.

            There are two different sets of keys for 32 bit and 64 bit applications.

            32 bit:

            HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

            Value Key: yourapplication.exe

            64 bit:

            HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

            Value Key: yourapplication.exe

            The value to set this key to is (taken from MSDN here) as decimal values:

            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.

             

            ok, 言盡至此,無(wú)話(huà)可說(shuō)了!

            作者:BobLiu 
            郵箱:lzd_ren@hotmail.com
            出處:http://www.cnblogs.com/liuzhendong
            本文版權(quán)歸作者所有,歡迎轉(zhuǎn)載,未經(jīng)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。

            posted on 2015-05-18 14:50 楊粼波 閱讀(1330) 評(píng)論(1)  編輯 收藏 引用

            評(píng)論

            # re: WebBrowser與IE的關(guān)系,如何設(shè)置WebBrowser工作在IE9模式下? 2015-05-18 14:51 楊粼波

            如果IE是6 7,那么控件就使用相應(yīng)的版本。

            如果IE是 8 9 ,控件默認(rèn) 是7,除非改注冊(cè)表,或者在html里面加入:
            <meta http-equiv="X-UA-Compatible" content="IE=11" />

            用了這么久這個(gè)控件,才知道原來(lái)是這么一回事。  回復(fù)  更多評(píng)論   


            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            久久久久高潮综合影院| 99久久国产亚洲高清观看2024 | 69久久夜色精品国产69| 久久久久亚洲av无码专区导航| 无码人妻精品一区二区三区久久| 人妻精品久久久久中文字幕69| 久久久久久国产精品免费无码 | 亚洲中文字幕无码久久综合网| 久久久精品国产免大香伊| 久久九九精品99国产精品| 久久综合狠狠综合久久激情 | 久久无码人妻一区二区三区| 久久99精品国产99久久| 亚洲精品国产第一综合99久久| 少妇内射兰兰久久| 国产国产成人久久精品| 精品久久久久久久国产潘金莲| 久久99精品久久久久子伦| 久久久久久青草大香综合精品| 伊人久久综合无码成人网| 亚洲综合精品香蕉久久网97| 久久夜色精品国产亚洲| 久久无码av三级| 中文字幕热久久久久久久| 精品久久久久久久久久中文字幕| 亚洲国产精品成人久久| 日日狠狠久久偷偷色综合免费| 久久久久亚洲AV无码专区体验| 久久午夜福利电影| 大伊人青草狠狠久久| 欧美日韩精品久久久免费观看| 欧美久久精品一级c片片| 精品久久久无码人妻中文字幕| 99久久精品国产一区二区三区| 人妻无码αv中文字幕久久琪琪布| 久久精品无码一区二区三区| 亚洲精品无码久久千人斩| 久久久久亚洲AV综合波多野结衣| 97久久综合精品久久久综合| 国内精品久久久久久久久电影网| 久久人人爽人人爽人人片AV东京热|