问题
I am currently using WebKit in C# .net. I am facing trouble while loading this page in WEBKIT. http://shop.orange.co.uk/mobile-phones/4g-ready-phones or http://www.vax.co.uk/ WEBKIT showing other web pages content successfully but in case of the above web page. there is a blank web page. there is not Page original Content. while this page is working fine in Firefox, Opera browsers. any help regarding this ? Infect this is not the only page. regards.
回答1:
I found no way to inspect or debug html/javascript with webkitdotnet project. And it seems it's not maintained a while.
So if you have ability to move to other web engines, I would recommend CefSharp - Embedded Chromium for .NET. It's powerful engine that, I believe, has all capabilities webkitdotnet has, and also it allows to attach Chrome browser inspector to debug the page. To do this, you need to set RemoteDebuggingPort property:
var settings = new CefSettings();
settings.RemoteDebuggingPort = 8088;
Cef.Initialize(settings);
Then you can open url http://localhost:8088 in your Chrome browser to attach embedded engine that runs in your app.
CefSharp project's sources contain examples of both WinForms and WPF applications. You can start easily with this examples.
UPDATE: In the moment of writing CefSharp component doesn't support taking full page snapshots as an image. I created ChromiumWebBrowserWithSnapshotSupport class in a forked branch https://github.com/ivan-sam/CefSharp . I've modified CefSharp.Wpf.Example project and added Snapshot button that makes snapshot of the page and opens an image. You also can put this control on WinForms form using ElementHost.
If you can't move, the only available option I see is to download affected page locally with all related content (scripts, css and so on), and host it with local web server. Then modify it to use Firebug Lite as described in this article (http://habrahabr.ru/post/154917/ - it's in Russian):
<!DOCTYPE html>
<html>
<head>
...
<script type='text/javascript' src='/path/to/firebug-lite.js'>
{
overrideConsole: true,
startInNewWindow: true,
startOpened: true,
enableTrace: true
}
</script>
...
</head>
<body>...</body>
</html>
and to allow Firebug to be open in a new window you should add the following C# code:
browser.Url = new Uri(
"http://localhost/path/to/debug-version-of-interface.html",
System.UriKind.Absolute);
browser.NewWindowCreated += new NewWindowCreatedEventHandler(
(sender, newWindowEventArgs) =>
{
// create new form with single item - Firebug Lite window
debuggerForm = new DebuggerForm(newWindowEventArgs.WebKitBrowser);
debuggerForm.Show();
});
Firebug lite gives you access to HTML DOM of the page and JavaScript console.
Happy debugging ^)
来源:https://stackoverflow.com/questions/20969294/webkit-showing-blank-page