js 中的alert title 在 iOS 中如何消失(未测试)
来源:互联网 发布:怎样看网络直播送礼物 编辑:程序博客网 时间:2024/06/13 18:27
在iOS app 中经常会嵌套html 代码, 然后 js 的alert 的title 怎么修改呢,不修改的话很丑陋,用户无法接受。如下:
但是现在有了好的办法就是用 iOS native 的uiwebview 的扩展方法来监听 js的alert 然后自定义 alert 的title ,如下:
这样就可以自定义, 也比较好看了。
方法是 在 你加在webview 的 m 方法中加入:
- @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 {
- UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"我是JS Alert"
- message:message
- delegate:nil
- cancelButtonTitle:@"确定"
- otherButtonTitles:nil];
- [customAlert show];
- [customAlert release];
- }
- @end
这样就ok了! 哈哈!
html 代码 :
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Webview document</title>
- <script type="text/javascript">
- function change_header()
- {
- alert("不错的一天");
- }
- </script>
- </head>
- <body style="background-color:transparent; color:white;">
- <h4>UIWebView HTML document</h4>
- <button onclick="change_header()">按钮</button>
- </body>
- </html>
0 0
- js 中的alert title 在 iOS 中如何消失(未测试)
- js 中的alert title 在 iOS 中如何消失
- js 中的alert title 在 iOS 中如何消失
- js 中的alert title 在 iOS 中如何消失
- js 中的Confirm title 在 iOS 中如何消失
- iOS开发 网页中的alert/contirm 点击方法未执行
- android在调用js中的alert无效
- java中实现js中的alert功能
- IOS中webview捕捉js中的alert 并修改标题和按钮
- alert在asp.net中如何使用??
- alert在asp.net中如何使用??
- Flex如何在Alert中显示超链接
- 如何在网页中加入title图标
- head中的title显示在body中
- js中的alert
- ios开发中WebView,去除(自定义)JS中Alert显示的网址
- js中alert()中文乱码
- JS 中alert总结
- Install xen-tools for VM on Xenserver
- android listview异步加载图片问题分析解决方案
- DedeCMS添加自定义字段调用不出值的解决办法
- Oracle 增删列,为列增加注释,修改主键等
- JQuery实现滑动banner轮番图
- js 中的alert title 在 iOS 中如何消失(未测试)
- 程序员应该逛的100个网站
- Java程序员从笨鸟到菜鸟之(五十三)细谈Hibernate(四)Hibernate常用配置文件详解
- Qt __FILE__,__LINE__
- CalTech machine learning, video 9 Review note(the Linear Model II)
- 获取IOS应用安装列表
- ubuntu内核list.h 的分析与应用
- JSP编程技术4-登录与注销(静态)
- jstl 及tiles在marven中引入