.h

#import <UIKit/UIKit.h>

@interface UIWebView (JavaScriptAlert)

-(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;

-(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;

@end

.m

#import "UIWebView+JavaScriptAlert.h"

@implementation UIWebView (JavaScriptAlert)

static BOOL diagStat = NO;

-(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame{

   UIAlertView* dialogue = [[UIAlertView alloc]initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];

  [dialogue show];

   [dialogue autorelease];

}

-(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame{

  UIAlertView* dialogue = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:NSLocalizedString(@"Okay", @"Okay") otherButtonTitles:NSLocalizedString(@"Cancel", @"Cancel"), nil];

  [dialogue show];

  while (dialogue.hidden==NO && dialogue.superview!=nil) {

  [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];

      }

   [dialogue release];

  return diagStat;

}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

   if (buttonIndex==0) {

   diagStat=YES;

  }else if(buttonIndex==1){

     diagStat=NO;

   }

}

@end

UIWebView 自定义网页中的alert和confirm提示框风格的更多相关文章

  1. Easyui中 messager.alert 后某文本框获得焦点

    messager.alert 后某文本框获得焦点 $.messager.alert({ title:'消息', msg:'电话号码 只能是数字!', icon: 'info', width: 300, ...

  2. JavaScript中的alert、confirm、prompt

    alert: var a=alert('Alert');//界面只有一個確定alert(a);   //返回值為undefined confirm: var c= confirm('Confirm') ...

  3. android中常用的弹出提示框

    转自:http://blog.csdn.net/centralperk/article/details/7493731 我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的 ...

  4. easyui confirm提示框 调整显示位置

    方法一: $.messager.confirm("确认对话框","该客户已经存在!确定:查看该客户 ", function(r){ if(r){ alert(& ...

  5. c#中的 MessageBox 弹出提示框的用法

    MessageBox.Show(<字符串str> Text, <字符串str> Title, <整型int> nType,MessageBoxIcon); 例:Me ...

  6. [转]jQuery插件实现模拟alert和confirm

    本文转自:http://www.jb51.net/article/54577.htm (function () { $.MsgBox = { Alert: function (title, msg) ...

  7. 模拟alert和confirm

    啥也不说,先上图,有图有真相 :) 现在绝大多数网站都不用自带的alert和confirm了,因为界面太生硬了.因此这个插件就这样产生了... 来看插件的实现代码吧: (function () { $ ...

  8. 自编jQuery插件实现模拟alert和confirm

    现在绝大多数网站都不用自带的alert和confirm了,因为界面太生硬了.因此这个插件就这样产生了自己定制一个的想法...... 啥也不说,先上图,有图有真相 :) 现在绝大多数网站都不用自带的al ...

  9. jquery控件-实现自定义样式的弹出窗口和确认框(转)

    (function () { $.MsgBox = { Alert: function (title, msg) { GenerateHtml("alert", title, ms ...

随机推荐

  1. 用tsung测试openfire 服务器性能

    最近公司需要做一个有聊天功能的应用,客户讲的是很宏大,用户超多,以前搞过openfire,但没有深入的去了解,就想用它来搞,而且是用 java写的,想扩展也容易些,但在性能上一直担忧,想测试一下它的性 ...

  2. careercup-栈与队列 3.4

    3.4 在经典问题汉诺塔中,有3根柱子及N个不同大小的穿孔圆盘,盘子可以滑入任意一根柱子.一开始,所有盘子自底向上从大到小依次套在第一根柱子上(即每一个盘子只能放在更大的盘子上面).移动圆盘时有以下限 ...

  3. magic_quotes_sybase(魔术引号开关)

    magic_quotes_sybase,如果该选项在php.ini文件中是唯一开启的话,将只会转义%00为\0(即null字符).此选项会完全覆盖magic_quotes_gpc.如果同时开启这两个选 ...

  4. Java基础知识强化之集合框架笔记52:Map集合之Map集合的遍历 键找值

    1. Map集合的遍历  Map -- 夫妻对 思路:  A:把所有的丈夫给集中起来.  B:遍历丈夫的集合,获取得到每一个丈夫.  C:让丈夫去找自己的妻子.  转换:  A:获取所有的键  B:遍 ...

  5. C#基础入门--关于C#背景介绍以及变量相关

    在正式探索C#的奥秘之前,我们先谈一谈关于学习方法的问题吧.你会不会有这样的感悟,自己努力奋斗得到的东西倍加珍惜,飘到眼前的,却不屑一顾.我认为,学习的整个历程亦是如此.在学习过程中,只有我们遇到了问 ...

  6. C# 序列化和反序列

    1.对象序列化的介绍 (1).NET支持对象序列化的几种方式 二进制序列化:对象序列化之后是二进制形式的,通过BinaryFormatter类来实现的,这个类位于System.Runtime.Seri ...

  7. Unity3D获取当前键盘按键

    获取当前键盘按键,代码如下: using UnityEngine; using System.Collections; public class GetCurrentKey : MonoBehavio ...

  8. PHP-popen()&nbsp;函数打开进程文件指针

    待更新 版权声明:本文为博主原创文章,未经博主允许不得转载.

  9. 将decimal类型的数值后面的0和.号去掉

    今天在群里面看到有朋友在问如下的需求,想到以前在写项目时也遇到这种处理数值的需求,所以写一个例子贴在博客里. 需求:在许多显示货币值时,可能需要截取掉后面的0,显示小数值或者整型值. 举例:(1)数据 ...

  10. PhpStorm 注册码

    JetBrains PhpStorm key PhpStorm注册码 User Name :  EMBRACE  License Key : License Key : ===== LICENSE B ...