开发者

Intercept navigation in webkit-sharp

开发者 https://www.devze.com 2023-01-28 17:52 出处:网络
I\'m investigating whether I can use webkit-sharp for my application. The main thing I need is the ability to handle custom URIs: I want to intercept link clicks and handle them myself, e.g. by call

I'm investigating whether I can use webkit-sharp for my application.

The main thing I need is the ability to handle custom URIs: I want to intercept link clicks and handle them myself, e.g. by calling WebView.LoadHtmlString. I suspect this can be done with the WebView.NavigationRequested event, but I don't immediately see a way to suppress the normal URI handling. I also can't find any reference docume开发者_如何学运维ntation for webkit-sharp or webkit itself.

Can it be done?


Apparently to suppress the normal URI handling, you have to set NavigationRequestedEventArgs.RetVal of the event arguments object to 1, which is the value of WEBKIT_NAVIGATION_RESPONSE_IGNORE in the webkit header files.


I know that in the Objective-C interface to WebKit you can use this WebPolicyDelegate method:

- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener

And if you want to handle the navigation yourself you use:

[listener ignore];

And if you want the default behavior you use:

[listener use];

Which you pretty much found out for your webkit-sharp implementation as I was typing this.

0

精彩评论

暂无评论...
验证码 换一张
取 消