Reputation: 8371
Short question: Is it possible to detect window.open()
in a UIWebView
using the UIWebViewDelegate
or is there another way to reach this? I need the the url when a window.open()
-Event is fired to show a UIAlertView
.
Upvotes: 8
Views: 8669
Reputation: 8371
You need to overwrite window.open()
using JavaScript:
[webView stringByEvaluatingJavaScriptFromString:@"window.open = function (open) { return function (url, name, features) { window.location.href = url; return window; }; } (window.open);"];
Upvotes: 16
Reputation: 1579
Try using this delegate methods. Hope this helps.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
- (void)webViewDidStartLoad:(UIWebView *)webView;
Upvotes: 0