I have a WebView which loads content from the Internet.
If I have a link which uses the ‘_blank’ attribute, nothing happens.
So far I have tried setting my WebView delegate but I can’t get it to register, I can’t even get an NSLog back so I must be using it wrong. The code is as follows:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[tmpView setUIDelegate:self];
}
- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
{
NSLog(@"HEY THERE");
return sender;
}
Ideally what I’d like, is that whenever a link is clicked on a WebView, the link is always opened within that WebView, nowhere else.
Is this possible?
Through research I found other methods but have no idea how to use them to get the result I desire:
webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:
I’m completely stumped so I’d really appreciate your help.
Thanks in advance everyone.
If you don’t want to open a new window but just open the request in your current
WebViewobject, you just need to do this in your delegate: