WebBrowser does not style new elements
-
Sunday, August 05, 2012 3:54 PM
I'm using the WebBrowser object to display geographical maps using Openlayers. In general it works well.
However I have spent ages trying to find out why some of the styling is missing when the page is loaded into the WebBrowser. Some web searches suggest that the WebBrowser only applies styles to elements that exist when the page is loaded. Of course the openlayers controls are created in the javascript that runs after the page has been loaded so I think that is the reason why the controls are not being fully styled.
The same page when loaded into several web browser applications (including IE9 on the same PC) has all of the openlayer controls fully styled.
Is there a way of forcing the WebBrowser to apply styles correctly to new elements as they are created, or to trigger the WebBrowser to re-apply styles to all currently existing elements?
All Replies
-
Monday, August 06, 2012 7:05 AMModerator
I think maybe it is caused by the Internet Feature Controls[FEATURE_BROWSER_EMULATION]: http://msdn.microsoft.com/en-us/library/ee330730(v=vs.85)#browser_emulation
Please set it to IE9 value then test the page.
If it cannot work for you, then please let's see your Visual Studio solution zip, and the repro steps, thanks.
You can use the skydrive to upload the files.
Mike Zhang[MSFT]
MSDN Community Support | Feedback to us
-
Monday, August 06, 2012 10:01 AM
Thanks. It is definitely the FEATURE_BROWSER_EMULATION. Reading up on this, it seems that the WebBrowser runs by default in IE7 compatibility mode, and you have to set a registry key to make it use a later version as described in the link you gave.
My PC has IE9 installed, and when I set the registry key to 9000 (IE9) the WebBrowser reports that it is using MSIE 9.0 compatibility mode and the controls are fully styled - great!
Strangely, if I set it to 8000 (IE8) the Web Browser reports that it is using MSIE 9.0 (not 8) compatibility mode, and yet the controls are NOT fully styled.
I conclude that at least IE9 mode is needed for the styling to work correctly. But the WebBrowser seems to be incorrectly reporting that it is using MSIE 9.0 mode when it is really using 8.0 mode.
As IE9 is not available for Windows XP, then does this mean that users on XP will have to put up with incomplete styling?
Also, what does WebBrowser do if it finds the registry key set to 9000 (IE9) when only IE7 or IE8 is actually installed? ( I don't have an XP machine handy to check this out).
Incidentally, I used this bit of javascript to report the compatibility mode:
var txt = "Browser Name: " + navigator.appName + "\n";
txt += "Browser Version: " + navigator.appVersion + "\n";
alert(txt); -
Tuesday, August 07, 2012 8:42 AMModerator
I think it is let the document know the documentMode and then use the corresponding render to rend the page.
And I'm using this page to do the test: http://www.enhanceie.com/ua.aspx
There's a Document mode link at the bottom part, you can click on it to see the current document mode info.
Mike Zhang[MSFT]
MSDN Community Support | Feedback to us
- Edited by Mike Dos ZhangMicrosoft Contingent Staff, Moderator Tuesday, August 07, 2012 8:43 AM
-
Wednesday, August 08, 2012 9:54 AM
Thanks for the link. It's interesting, but only of use if you are able to structure the style sheets etc on the server. Also the lack of complete styling may be due to a lack of support for some styles in the compatible version of IE rather than something that can be fixed just by getting the browser to pretend to be another version through the user-agent. OpenLayers is a self-contained library, so I'll drop them a line.
-
Thursday, August 09, 2012 3:15 AMModerator
You're welcome!
I think this forum would be helpful to you to research deeply about the WebBrowsers user-agent and other things: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/threads
Have a good day!
Mike Zhang[MSFT]
MSDN Community Support | Feedback to us


