zoukankan      html  css  js  c++  java
  • iOS Webview 实现修改javascript confirm 和 alert

    @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

  • 相关阅读:
    二 关键词关键词扩展(五)
    二 关键词关键词竞争程度判断(三)
    discuz X2.5 门户diy风格模版制作教程
    二 关键词关键词分布(六)
    seo各种跳转
    js 判断未定义
    网站运营赚钱的小心得
    二 关键词核心关键词(四)
    asp实现301跳转的方法
    UVA 11258 String Partition
  • 原文地址:https://www.cnblogs.com/lein317/p/5067540.html
Copyright © 2011-2022 走看看