Ales Rosina's blog

shelastyle.net
Subscribe

WebKit vs. IE browser control in C#



 

Recently I needed to include a web browser control (in Windows Forms project), so the logical choice would be WebControl, which is actually only .NET wrapper around Internet Explorer’s ActiveX control.

Well, I wanted to try some other engines, like WebKit (which is core of Apple Safari, Google Chrome, Adobe AIR, etc.), since IE engine (called Trident) scores on Acid3 very low (13 out of 100) and WebKit engine scores almost perfect (99 out of 100). For most cases this is not important, since most of web pages are done with optimizations for all browsers, but sometimes it is.

So for this test I’ve created very simple application, where you can compare those two rendering engines (you can download this app here, if you’re not interested in code).

I have run this app on a different sites and found out, that WebKit renders pages faster, if there is a lot of JavaScript behind, where simple plain HTML pages is rendered faster by Internet Explorer engine. So based on that, you have to decide which control to use in your application.

acid3 
For WebKit implementation I’ve used WebKit.NET, which is using Cairo derivate of WebKit (how to build it on your own, read here) and already includes binaries, so all you need to do, is to include WebKitBrowser in your toolbox in Visual Studio (right click on Toolbox > Choose items > .NET Framework Components > Browse… and select WebKitBrowser.dll from previously downloaded zip file) and drag it into your Form. Using this component is basically the same as using WebBrowser control, so you start navigation with

webBrowser1.Navigate(textBox1.Text);


and do something when document is loaded on event:

private void webBrowser1_DocumentCompleted(
object sender, WebBrowserDocumentCompletedEventArgs e) { //... }
And that’s it, you just created a very simple web browser.

You can download project (with source code) here, so you can play with code or if you want only app, download it here.
Reblog this post [with Zemanta]
   

author: Aleš Rosina | Comments: 14 | Tags: , , ,
07
February
2010

 
Faheem on 23. February 2010 at 07:58

Hi tried the web kit works like a charm.

I was building an application which used google earth(geplugin)

to show the earth in a browser control in c#.net

Recently google launched chrome frame. now i am unable to load the same document as now google earth uses chrome frame to route everything through google chrome. I have added the meta tag as they insisted but still the chrome frame was unable to load... Anyways my question was...

that for the default web browser control in c#.net wrapping IE i used to use.

this.wbOnline2DMap.Document.InvokeScript("FlyHere", new string[] { this.tbMapTxtLocation.Text });

inorder to invoke an external javascript method from my app. Cant find this function in webkit bowser. Any help please urgently...

Faheem on 23. February 2010 at 08:11

hi

Need to call javascript function from c#.net

I did this in the traditional IE browser control in c#.net

this.wbOnline2DMap.Document.InvokeScript("FlyHere", new string[] { this.tbMapTxtLocation.Text });

what should i do for web kit browser control

faheem on 23. February 2010 at 08:12

sorry for the multiple posts. got some errors on my page

Adnan on 21. July 2010 at 08:12

Is there any tutorial for beginners which deals with navigation a URL to manipulating DOM or accessing Javascript?

thx

homayun.kabir on 26. August 2010 at 08:38

I face this below problem when I tried to use it

Could not load type 'WebKit.WebKitBrowser' from assembly 'WebkitBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

can anybody pls assist me to recover it?

Aleš Rosina on 26. August 2010 at 11:12

Did you read tutorial from webkitdotnet.sourceforge.net/.../webkit.php this url and added DLL to references in your project?

cloud computing on 10. May 2011 at 05:04

It is amazing to see the scores of Webkit on the acid3 because this type of results cannot be seen on IE it always show low scores which is not appreciable. Even Firefox does not show high scores it shows approximately 53. I think this apple originated Webkit is the first browser to score high rank in the acid3.

Murad on 6. June 2011 at 11:21

Hi, This WebKit control could not open any site except Google. What is the problem? please reply.

Murad on 7. June 2011 at 12:15

.Net WebBrowser control has "document" property which is very important to work but I could not find it in Webkit.

Please reply with example, how can I handle this by Webkit.

Gyanesh on 11. October 2011 at 15:16

could you please help me in implementing a click event of button within the webkit browser through coding , example if a site is loaded in the webkit browser then from that site i need to click any button through coding.

isaac on 6. January 2012 at 03:27

could i use this control in wpf application ?

Kevin on 6. January 2012 at 23:44

Thanks for the informative post. Using the WebkitBrowser control how can I load an html file from disk? I have tried file:///C:/path_to_html/htmfiletoload.html with no success.

isaac on 18. January 2012 at 23:59

im using the webkit browser control in visual studio express 2010 on vb.net

im using a tabcontrol and im adding tabs dynamic when clicking on a link

and i cant figure out " how capture the new Url "

so i would know what to open the new tab

there is a tabcontrol and two tabs open already

on each tab there is a webkit browser control

this is the code:

Private Sub WebKitBrowser1_NewWindowRequest1(ByVal sender As Object, ByVal args As WebKit.NewWindowRequestEventArgs) Handles WebKitBrowser1.NewWindowRequest

'newOpenedWindow is a WebkitBrowser control in another tab

newOpenedWindow.Navigate(args.Url)

newOpenedWindow.Dock = DockStyle.Fill

End Sub

petra on 1. February 2012 at 17:33

Petra was elected as a headquarter of the Nabateans for the reason that it was situated in a basin bordered by mountains of sandstones. There are several routes that lead into the capital, but not a single of them are unchallenging, and in case the gorges are closed, it is nearly unfeasible for any person to get inside the city.

Leave a Comment

Name:
Email:
I respect your privacy, so your email is never published.
Web site: