I found a strange behavior in the component TwebBrowser, when I load certain pages they are shown with larger fonts. different from what is used in internet explorer.
see these sample images
Here in this link http://docwiki.embarcadero.com/RADStudio/en/Main_Page is loaded with larger fonts in TWebBrowser and with small fonts (another style) in IE.
this page https://stackoverflow.com/ is loaded with same style in the TWebBrowser component and IE.
I tried it on different machines and same thing happens.
how can i fix this behavior ? this is a problem with a CSS?
I think the problem is that the TWebBrowser
component is running Internet Explorer in compatibility mode. Indeed, if you open the docwiki page in Internet Explorer 8 and later, the fonts are small and pleasant, in contrast to how they look in the TWebBrowser
. But if you click the "Compatibility View" button in the Internet Explorer window, you will get the same large text as you do get in the TWebBrowser
component. (It is well-known that IE6 use too large text.)
According to this MSDN blog entry and the MSDN docs, to control the compatibility mode of the TWebBrowser
control, use the registry:
procedure TForm3.FormCreate(Sender: TObject);
begin
with TRegistry.Create do
try
RootKey := HKEY_CURRENT_USER;
if OpenKey('Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', true) then
WriteInteger(ExtractFileName(Application.ExeName), 8888);
finally
Free;
end;
WebBrowser1.Navigate('http://docwiki.embarcadero.com/RADStudio/en/Main_Page');
end;
The values are 8000, 7000, and 8888 for "IE8 Standards Mode", "IE7 Standards Mode", and "IE8 Standards Mode (Forced)", respectively. Hence, the above code will force IE8 standards mode.
Surprisingly, however, setting the mode to standard will only make the font even larger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With