js 中的alert title 在 iOS 中如何消失
来源:互联网 发布:青稞的网络意思 编辑:程序博客网 时间:2024/06/14 07:47
在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>
- js 中的alert title 在 iOS 中如何消失
- js 中的alert title 在 iOS 中如何消失
- js 中的alert title 在 iOS 中如何消失
- js 中的alert title 在 iOS 中如何消失(未测试)
- js 中的Confirm title 在 iOS 中如何消失
- android在调用js中的alert无效
- java中实现js中的alert功能
- IOS中webview捕捉js中的alert 并修改标题和按钮
- alert在asp.net中如何使用??
- alert在asp.net中如何使用??
- Flex如何在Alert中显示超链接
- 如何在网页中加入title图标
- head中的title显示在body中
- js中的alert
- JS 中alert总结
- 关于在cs文件中输出js的alert代码
- Cocos2d-js h5游戏在 微信中打开时,点击屏幕后 微信上方title标题消失。
- js中的alert()弹出乱码
- Oracle中循环语句的触发器
- iBATIS与Spring整合
- How to encrypt a string/stream with bouncycastle pgp without starting with a file
- 通过web页面上的链接调用本地软件
- Ubuntu 安装 Qt 开发环境
- js 中的alert title 在 iOS 中如何消失
- 使用CreateProcess运行程序 + 使用命令行对html文件进行打印
- c语言中realloc()函数解析
- ov2656
- Android ListView分类/分组效果 - 第二种实现方式
- android 休眠唤醒
- MFC的CFile
- 黑马程序员--高新技术(2)
- redis持久化机制