iOS Webview 实现修改javascript confirm 和 alert
2015-01-09 14:59
435 查看
@interface UIWebView (JavaScriptAlert) -(void) webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame; - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame; @end @implementation UIWebView (JavaScriptAlert) - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame { UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"助手提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [customAlert show]; } static BOOL diagStat = NO; static NSInteger bIdx = -1; - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame { UIAlertView *confirmDiag = [[UIAlertView alloc] initWithTitle:@"助手提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [confirmDiag show]; bIdx = -1; while (bIdx==-1) { //[NSThread sleepForTimeInterval:0.2]; [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1f]]; } if (bIdx == 0){//取消; diagStat = NO; } else if (bIdx == 1) {//确定; diagStat = YES; } return diagStat; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ bIdx = buttonIndex; } @end
相关文章推荐
- iOS Webview 实现修改javascript confirm 和 alert
- iOS Webview 实现修改javascript confirm 和 alert
- IOS中webview捕捉js中的alert 并修改标题和按钮
- iOS 混合应用的关键点分析 - 仿 Android 平台 WebView 可注入本地对象方法的功能实现要点
- iOS中修改WebView默认的User Agent
- iOS学习之WebView的使用--实现打开网页
- iOS-webview内的UA修改
- iOS_11_tableViewCell的使用alertView修改数据
- iOS WebView 如何通过js获取网页中所有图片并加入点击事件,实现浏览图片的功能
- iOS中修改WebView默认的User Agent
- iOS实现WebView上图片放大 用法及原理
- iOS 修改webView字体大小,设置宽度及缩放效果
- iOS学习之WebView的使用 (主要是下面的全屏半透明实现)
- ios开发中WebView,去除(自定义)JS中Alert显示的网址
- iOS WebView修改字体、大小、颜色
- IOS修改webView背景透明以及IOS调用前台js的方法
- [IOS] 自定义AlertView实现模态对话框
- iOS学习之WebView的使用 (主要是下面的全屏半透明实现)
- IOS: 自定义AlertView实现模态对话框
- ios中自定义alert view,并实现动画组合