I use WKWebView to show a web page. When I touch a button on the page, some javascript code should work and show me an alert view. But it doesn't work. If I open the page on Safari, it works well. Here is my code
WKWebViewConfiguration *configuration = [WKWebViewConfiguration new];
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.preferences.javaScriptEnabled = YES;
_webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:configuration];
self.view = _webView;
NSURLRequest *req = [NSURLRequest requestWithURL:[HPBNetworkBusiness getExamPageURL]];
[_webView loadRequest:req];
[_webView addObserver:self forKeyPath:@"URL" options:NSKeyValueObservingOptionNew context:nil];