iphone--UIWebView中js弹出框修改-

来源:互联网 发布:数据库软件市场份额 编辑:程序博客网 时间:2024/06/09 15:36
我们在使用UIWebView中使用调用javascript代码:

<script type="text/javascript">
    alert("ok!");
</script>

弹出来以后的对话框的标题是该页面的网址,按钮的标题也是英文的,非常不美观,可以使用以下方法解决;

在.m或.n文件中加入

@interface UIWebView (JavaScriptAlert) - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;@end@implementation UIWebView (JavaScriptAlert)- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {        NSLog(@"javascript alert : %@",message);        UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];        [customAlert show];        [customAlert autorelease];    }@end

runJavaScriptAlertPanelWithMessage是WebUIDelegate的成员函数,详情可以查阅WebUIDelegate的帮助文档

这样做使用私有方法,不知会不会影响审核呢??

原创粉丝点击