原理是这样的,当alert弹出框点击确定以后,再让页面重新加载一下就可以,具体代码如下:<script type="text/javascript">alert("提交成功!")window.location.reload()</script>NSString* methodNameStr=[NSString stringWithFormat:@"device_callback(%d,\"%@\")",[@"6001" isEqualToString:@"6001"]?-1:-2,[@"6001" isEqualToString:@"6001"]?@"取消":@"失败"]
如果在通知方法里直接调用
[weakSelf.webView stringByEvaluatingJavaScriptFromString:methodNameStr]
会弹出alert 但是点击不了
所以不能这样写
NSString *jsMyAlert =[NSString stringWithFormat:@"setTimeout(function(){%@},1)",methodNameStr]
[weakSelf.webView stringByEvaluatingJavaScriptFromString:jsMyAlert]