Reputation: 58619
On OSX, I am using XCode to make a desktop app with a webview in it. The webview loads ok, and I can dynamically load content into it - but when I click on links inside the webview, they are not followed. They change color, but no new page is loaded. If I code my links with javascript like this - then they work.
<a href='http://x/' onClick="window.location = this.href">link there</a>
Is there an Objective-C one liner that allows links to be followed inside web-views?
Is there another issue I am not aware of here?
Upvotes: 0
Views: 1218
Reputation: 58619
Turns out it was because I had code I copied form the web with some custom function to ignore WebPolicyDecisionListener...
Sorry for asking question without giving all the details - all this objective-c is new to me, I don't know which bits do what yet. I do some pointing and clicking, and then some coding - I don't know exactly how that all links up. With other languages, you have the whole program in one place - it takes a bit of a learning curve to get used to... but I digress.
I fixed by adding some comments - see code below...
- (void)webView:(WebView *)aWebView
decidePolicyForNavigationAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request
frame:(WebFrame *)frame
decisionListener:(id < WebPolicyDecisionListener >)listener
{
if ([self requestIsLinkClick:actionInformation]) {
if ([@"method" isEqual:[[request URL] scheme]]) {
SEL selector = NSSelectorFromString([[request URL] resourceSpecifier]);
if ([prototypeDelegate respondsToSelector:selector]) {
[prototypeDelegate performSelector:selector];
}
}
// [listener ignore];
} // else {
[listener use];
//}
}
Upvotes: 0
Reputation: 53561
The links at the top of Gmail open in a new window. To make them work you have to implement at least the WebUIDelegate
methods webView:createWebViewWithRequest:
and webViewShow:
. If you simply want to open all links in the same web view, you could return it from webView:createWebViewWithRequest:
instead of creating a new one.
Upvotes: 6