b***@aliyun.com
b***@aliyun.com
  • 发布:2017-05-27 17:57
  • 更新:2018-11-29 21:53
  • 阅读:1224

iOS overrideUrlLoading无法拦截自定义协议

分类:5+ SDK
embed.overrideUrlLoading({mode:"reject"}, function(e){  
        console.log("---overrideUrlLoading--");  
        alert(e.url);  
        console.log(e.scheme);  
        console.log("reject url: "+e.url);  
    });

服务器端web:

 <div><a href="tel:15502162569">call me</a></div>  
      <div><a href="http://m.baidu.com">baidu</a></div>  

      <div><a href="intent://pay?id=123456&name=ftd">pay</a></div>  

      <div><a href="saas://pay?id=007&name008">pay now</a></div>  

      <div><a href="http://otosaas/pay?id=hhh&name=ttt">http pay</a></div>

Android手机上完全没问题;iOS手机行就拦截不到自定义的协议,点击完全不走overrideUrlLoading方法,请问什么原因呢

2017-05-27 17:57 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

上传一个可以重现上述问题的例子。

提供一下所使用的HBuilder的版本信息。

iOS环境,只拦截https、http、file协议。

  • 撸三发

    回复 撸三发:<!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <title></title>

    </head>

    <body>

    <div>

    <div><a href="http://m.baidu.com">baidu</a></div>


          <div><a href="intent://pay?id=123456&name=ftd">pay</a></div>  

    <div><a href="saas://pay?id=007&name008">pay now</a></div>

    <div><a href="http://otosaas/pay?id=hhh&name=ttt">http pay</a>

    </div>
    </body>

    </html>

    2017-09-21 17:09

  • 撸三发

    回复 撸三发:使用的hbuilder是最新版本8.8.0.201706142254

    2017-09-21 17:10

  • 撸三发

    上面demo是在ios环境下,只拦截http协议的,自定义协议拦截不了

    2017-09-21 17:11

  • 撸三发

    回复 撸三发:<!DOCTYPE html>

    <html>

    <head>

    <meta http-equiv="content-type" content="text/html;charset=utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="format-detection" content="telephone=no"/>

    <meta name="keywords" content="首页" />

    <meta name="description" content="首页" />

    <title>首页</title>

    <link rel="stylesheet" type="text/css" href="css/mui.css"/>

    <script src="js/mui.js" type="text/javascript" charset="utf-8"></script>

    </head>

    <body>

    <script type="text/javascript">

    var url = "test1.html";

    var embed=null;

    // H5 plus事件处理

    function plusReady(){

    var styles={};

    // 在Android5以上设备,如果默认没有开启硬件加速,则强制设置开启

    if(!plus.webview.defaultHardwareAccelerated()&&parseInt(plus.os.version)>=5){

    styles.hardwareAccelerated=true;

    }

    embed=plus.webview.create(url,"",{top:"44px",bottom:"0px",popGesture:"show",cachemode:"noCache"});

    plus.webview.currentWebview().append( embed );

    embed.overrideUrlLoading({

    mode: "reject",

    match: ".*"

    }, function(e){

    mui.toast(JSON.stringify(e));

    },function(e){

    console.log(JSON.stringify(e));

    });

    }

    if(window.plus){

    plusReady();

    }else{

    document.addEventListener("plusready",plusReady,false);

    }

    </script>

    </body>

    </html>

    2017-09-21 17:12

kaiven

kaiven

这个问题解决了吗?新版还是遇到同样的问题

该问题目前已经被锁定, 无法添加新回复