diff --git a/NJKWebViewProgress/NJKWebViewProgress.m b/NJKWebViewProgress/NJKWebViewProgress.m index 46b6bad..e5d0214 100644 --- a/NJKWebViewProgress/NJKWebViewProgress.m +++ b/NJKWebViewProgress/NJKWebViewProgress.m @@ -132,7 +132,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView BOOL interactive = [readyState isEqualToString:@"interactive"]; if (interactive) { _interactive = YES; - NSString *waitForCompleteJS = [NSString stringWithFormat:@"window.addEventListener('load',function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@://%@%@'; document.body.appendChild(iframe); }, false);", webView.request.mainDocumentURL.scheme, webView.request.mainDocumentURL.host, completeRPCURLPath]; + NSString *waitForCompleteJS = [NSString stringWithFormat:@"function notifyLoading(){ var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@://%@%@'; document.body.appendChild(iframe); }; var whenReady = function(callback) { if (document.readyState === 'complete') { callback(); } else if (document.addEventListener) { document.addEventListener('DOMContentLoaded', callback); } }; whenReady(notifyLoading());", webView.request.mainDocumentURL.scheme, webView.request.mainDocumentURL.host, completeRPCURLPath]; [webView stringByEvaluatingJavaScriptFromString:waitForCompleteJS]; }