問題描述
我在我的 winforms 應(yīng)用程序中使用 WebBrowser 控件和 Smooth Div Scroll 來呈現(xiàn) html 選取框.我下載了示例并添加了
I use the WebBrowser control and Smooth Div Scroll in my winforms application to render a html marquee. I downloaded the sample and added
autoScrollingInterval: 3
到
$("div#makeMeScrollable").smoothDivScroll({
autoScrollingMode: "onStart"
});
讓它移動得更快.當(dāng)我在 IE 中打開示例時,它工作得很好,但是當(dāng)我使用 WebBrowser 控件并調(diào)用導(dǎo)航方法時,滾動條的移動速度要慢得多.
to make it move faster. When I open the sample in IE it works just fine but when I use the WebBrowser control and call the navigate method the scroller moves much slower.
是什么導(dǎo)致了這個問題?
What is causing this problem?
推薦答案
據(jù)我了解,您正在處理的問題是 IE 7 標(biāo)準(zhǔn)模式下的 WebBrowser Control 呈現(xiàn)和您使用的實(shí)際 WebBrowser 的版本控制問題IE 是 IE 8 或 IE 9,它在那里工作,但你的 JQuery/JavaScript 或 CSS 包含在 IE 7 中不起作用.
As I understand it, the issue you are dealing with is a versioning issue with the WebBrowser Control rendering in IE 7 Standard Mode and the actual WebBrowser you are using in IE is either IE 8 or IE 9, and it works there, yet your JQuery/JavaScript or CSS inclusions are not working in IE 7.
讓我直截了當(dāng)?shù)馗嬖V你.默認(rèn)渲染引擎開啟webbrowser 控件是固定的,以確保在所有的兼容性平臺.
Let me tell you this straight up. The default rendering engine on the webbrowser control is fixed to ensure compatibility across all platforms.
基本上,如果你安裝的瀏覽器是 IE 7 - IE 9,那么使用的渲染引擎僅 IE 7.0(默認(rèn)).
Basically, if you're installed browser is IE 7 - IE 9, then the rendering engine used is IE 7.0 only (by default).
但是,如果您安裝的 IE 版本是 IE 6 或更低,那么使用的渲染引擎是 IE 4.0(不是開玩笑),當(dāng)然除非你否則設(shè)置它.
If, however, your installed IE version is IE 6 or below, then the rendering engine used is IE 4.0 (not kidding), unless of course you set it otherwise.
有一種誤解認(rèn)為 WebBrowser 控件使用任何當(dāng)前已安裝(當(dāng)前 IE 版本),但事實(shí)并非如此,因?yàn)樗麄冞@樣做是為了減少向后兼容性問題.你可以看到(作為證據(jù))這確實(shí)是你的問題www.whatsmyuseragent.com 在您的普通瀏覽器中,然后轉(zhuǎn)到該網(wǎng)站再次在您的 WebBrowser 控件中,您將看到它說 MSIE 7.0 :).
There is a misconception that WebBrowser control uses whatever is currently installed (current IE version) but this is not true, since they do this to reduce backward compatibility issues. You can see (as proof) that this really is your problem by going to www.whatsmyuseragent.com in your normal browser, and then going to that website again in your WebBrowser control, you will see that it says MSIE 7.0 :).
您可以將其設(shè)置為使用當(dāng)前安裝的互聯(lián)網(wǎng)版本資源管理器,在頁面內(nèi)使用 META 標(biāo)記,或編輯注冊表在將運(yùn)行 webbrowser 控件的機(jī)器上(編輯Current_User 和 Local_Machine 都可以工作).
You can set it to use the current installed version of internet explorer, either using a META tag in-page, or editing the Registry on the machine where the webbrowser control will run (editing for Current_User and Local_Machine will both work).
WebBrowser 控件將(通常)使用您所使用的任何版本的 IE已安裝,但出于兼容性原因,它將呈現(xiàn)頁面默認(rèn)在 IE7 標(biāo)準(zhǔn)模式下.
WebBrowser control will (normally) use whatever version of IE you have installed, but for compatibility reasons it will render pages in IE7 Standards mode by default.
如果您想利用新的 IE9 功能,您應(yīng)該添加元標(biāo)記 <meta http-equiv="X-UA-Compatible" content="IE=9" >
在 HTML 頁面的 <head>
標(biāo)記內(nèi).
If you want to take advantage of new IE9 features, you should add
the meta tag <meta http-equiv="X-UA-Compatible" content="IE=9" >
inside the <head>
tag of your HTML page.
必須在任何指向 CSS、JavaScript 的鏈接之前添加此元標(biāo)記<head>
中的文件等也可以正常工作(僅其他 <meta>
標(biāo)簽或 <title>
標(biāo)簽可以在它之前).
This meta tag must be added before any links to CSS, JavaScript
files etc that are also in your <head>
to work properly though (only
other <meta>
tags or the <title>
tag can come before it).
另一種方法是將注冊表項(xiàng)添加到:
An alternative is to add a registry entry to:
HKLM > 軟件 > 微軟 > Internet Explorer > 主要 >FeatureControl > FEATURE_BROWSER_EMULATION
HKLM > SOFTWARE > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION
并在其中添加值為9000"的YourCompiledApplicationName.exe"到強(qiáng)制 WebBrowser 控件以 IE9 模式顯示頁面.盡管您也可以使用其他值,請注意這些文檔不完全準(zhǔn)確,因?yàn)樗坪鯚o法獲取頁面以 IE 8 模式呈現(xiàn)您使用的任何值.(注意:YourCompiledApplicationName.exe 必須是您編譯的包含 WebBrowser 控件的 EXE 文件名,它僅適用于您已包含在注冊表中的文件名).此外,添加 vshost.exe 和 YourCompiledApplicationName.exe.svchost 不會有什么壞處,因此它在通過您的 IDE 運(yùn)行時可以工作,而且,如果您的應(yīng)用程序在 64 位 Windows 下運(yùn)行,您可能還應(yīng)該在以下注冊表路徑下設(shè)置以下 DWORD到相同的值(根據(jù) 32 位路徑):
And in there add 'YourCompiledApplicationName.exe' with value '9000' to force the WebBrowser control to display pages in IE9 mode. Though there are other values you can use too too, note that these docs aren't entirely accurate as it does not seem possible to get a page to render in IE 8 mode whatever value you use. (Note: YourCompiledApplicationName.exe must be the EXE file name that you compile which contains your WebBrowser Control, it will only work for the file name that you've included in the registry). Also, it wouldnt hurt to add vshost.exe and YourCompiledApplicationName.exe.svchost so it works when run through your IDE, and also, If your app is running under 64bit Windows, you likely should also set the following DWORD under the following registry path to the same value (as per the 32bit path):
HK[LM|CU]SOFTWAREWow6432NodeMicrosoftInternet ExplorerMainFeatureControl FEATURE_BROWSER_EMULATION
HK[LM|CU] SOFTWARE Wow6432Node Microsoft Internet Explorer Main FeatureControl FEATURE_BROWSER_EMULATION
將注冊表項(xiàng)添加到 HKCU 中的同一路徑而不是 HKLM也可以 - 這很有用,因?yàn)閷懶沤o HKLM 需要管理員HKCU沒有的特權(quán).
Adding the registry key to the same path in HKCU instead of HKLM will also work - this is useful as writing to HKLM requires admin privileges where as HKCU does not.
如果 WebBrowser 控件,不確定 IE 10.0 何時出現(xiàn)默認(rèn)引擎將轉(zhuǎn)到 10.0(如果 10.0 安裝在當(dāng)然)或者即使在 IE 10.0 之后它仍將保持為 IE 7.0發(fā)布,我們將不得不看到它一旦出來.然而,如果我們根據(jù)以前的經(jīng)驗(yàn)猜測,我懷疑 IE 10.0 將是最后一個使用 IE 7.0 渲染引擎的版本,當(dāng) IE 11 到來時出,默認(rèn)渲染引擎將保持為 IE 11 為所有IE 11 和 IE 之間的 IE 版本IE 14. 這只是一個猜測推斷他們過去所做的事情.
Not sure if when IE 10.0 comes out if the WebBrowser controls default engine will go to 10.0 (if 10.0 is installed on system of course) or if it will remain as IE 7.0 even after IE 10.0 is released, we will have to see once it comes out. However, if we guess based on previous experience, i suspect IE 10.0 will be the last version that uses IE 7.0 rendering engine, and when IE 11 comes out, the default rendering engine will remain as IE 11 for all versions of IE between IE 11 & IE 14. This is just a guess by extrapolating what they've done in the past.
有關(guān)可以將注冊表設(shè)置為的值的詳細(xì)信息,看看這個:
For more information on the values you can set the registry to,check this out:
這篇關(guān)于腳本在 dotnet WebBrowser 控件中運(yùn)行速度較慢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!