Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect window.open() from UIWebView

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.

like image 965
Fabio Poloni Avatar asked Jun 06 '12 06:06

Fabio Poloni


1 Answers

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);"];
like image 178
Fabio Poloni Avatar answered Sep 19 '22 19:09

Fabio Poloni