示例网址:https://unifiedportal-mem.epfindia.gov.in/memberinterface/ 单击“忘记密码”,然后输入UAN为:101010101010键入验证码并提交。
如何在该页面上显示didFinish?加载后如何获得“ UAN无效”消息。
由于已加载页面,因此webView的didFinish功能在这种情况下不起作用。
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!{
}
尝试以下方法,但没有响应。得到了
Error Domain = WKErrorDomain代码= 5“ JavaScript执行返回了不支持的类型的结果” UserInfo = {NSLocalizedDescription = JavaScript执行返回了不支持的类型的结果}
let s = """
var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener("load", function() {
var message = {"status" : this.status, "responseURL" : this.responseURL}
webkit.messageHandlers.handler.postMessage(message);
});
open.apply(this, arguments);
};
"""
weakSelf.webView.configuration.userContentController.removeScriptMessageHandler(forName: "myInterface") // to delete existing
weakSelf.webView.configuration.userContentController.add(weakSelf as WKScriptMessageHandler, name: "myInterface")
weakSelf.webView?.evaluateJavaScript(s, completionHandler: {(string,error) in
print(error ?? "no error")
})