JS H5界面简单交互
2016-05-23 00:00
423 查看
摘要: H5 iOS交互
原生向H5传值的话,约定空方法进行接收
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"box(%d)",delegate.isLogined]];
相反:
webView代理方法里:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
}
截取当前发生行为的链接
NSString *requestString = [[request URL] absoluteString];
前端约定点击跳转链接进行判断是否允许发生跳转 或者跳回原生App
if( navigationType == UIWebViewNavigationTypeOther ) {
if ([requestString hasPrefix:[NSString stringWithFormat:@"%@/product_details/BuyPageCommon.aspx",BASE_URL]]&&delegate.isLogined) {
}
}
原生向H5传值的话,约定空方法进行接收
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"box(%d)",delegate.isLogined]];
相反:
webView代理方法里:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
}
截取当前发生行为的链接
NSString *requestString = [[request URL] absoluteString];
前端约定点击跳转链接进行判断是否允许发生跳转 或者跳回原生App
if( navigationType == UIWebViewNavigationTypeOther ) {
if ([requestString hasPrefix:[NSString stringWithFormat:@"%@/product_details/BuyPageCommon.aspx",BASE_URL]]&&delegate.isLogined) {
}
}
相关文章推荐
- 初学javaScript-js函数和c函数的比较。
- JavaScript入门(一)
- JSON详解
- c#处理3种json数据的实例
- Newtonsoft.Json(Json.Net)学习笔记
- JavaScript处理HTML的Encode(转码)和Decode(解码)
- js格式化时间
- javascript中的事件
- js图片放大缩小
- 发起JSONP请求
- js格式化日期
- js 判断 用户浏览器所在平台
- JS如何实现抛物线动画
- threejs(二) 移动,相机
- 谈一谈Javascript内存释放那点事
- js中的prototype_记录
- 关于JSP中PreparedStatement的使用
- 如何将JS里变量的值赋给文本框
- 智能社JavaScript基础--1~7节课程.docx
- JavaScript eval()表达式