热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

webview调用系统浏览器怎么解决

mui的页面,也就是webview的页面中包含多个list,每次点击其中一个list时,希望是在手机的浏览器中打开,不要在webview中打开,要怎么操作呢?mui的open方法是不能用

mui的页面,也就是webview的页面中包含多个list,每次点击其中一个list时,希望是在手机的浏览器中打开,不要在webview中打开,要怎么操作呢?
mui的open方法是不能用的,location.href / windown.open 都不起作用。

如果把点击事件放在mui.plusReady(function(){}中,因为用到5+,但是在手机上测试时,点击也不跳转:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
mui.plusReady(function(){

    if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE){

        mui.toast("当前网络不给力,无法加载广告");

    }else{

        //屏幕真实宽度

        var width = window.innerWidth;

        var height = window.innerHeight;

       

        var adHeight = parseInt(width)*3/20;

        var adBottom = mui.os.ios?('-'+adHeight+'px'):'0';

        var ad = plus.webview.create(url,'ad',{height:adHeight+'px',bottom:adBottom,position:"absolute"});

       

        //目前Android平台不支持子webview的setStyle动画,因此分平台处理;

        if(mui.os.ios){

            //为了支持iOS平台左侧边缘滑动关闭页面,需要append进去;

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

            ad.addEventListener('loaded',function () {

                ad.setStyle({

                    bottom:'0',

                    transition: {

                        duration: 150

                    }

                });

            });

        }else{

            ad.addEventListener('loaded',function () {

                ad.show('slide-in-bottom');

            });

        }

        //设置主页面的底部留白,否则会被遮住;

        document.querySelector('.mui-content').style.paddingBottom = adHeight + 'px';

    }

   

    //点击打开下载的文件

    jQuery('#downloadNav').find('.download-name').on('tap',function(e){

        e.stopPropagation();

        var url = jQuery(this).attr('url');

        var href = this.getAttribute('href');

        if (url) {

            if (window.plus) {

                plus.runtime.openURL(url);

            } else {

                location.href = url;//在网页中执行这一句,报个警告

                //警告信息:mui.min.js:7 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

            }

        }

    });

})

如果把点击事件放在mui.ready(function() {}中,在网页测试时,是可以点击到的,也会正常跳转;但在手机上测试,不跳转:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mui.ready(function() {

    //点击打开下载的文件

    jQuery('#downloadNav').find('.download-name').on('tap',function(e){

        e.stopPropagation();

        var url = jQuery(this).attr('url');

        var href = this.getAttribute('href');

        if (url) {

            if (window.plus) {

                plus.runtime.openURL(url);

            } else {

                location.href = url;//仍然是执行的这一句,同样也有警告

                //警告信息:download.html:297 Resource interpreted as Document but transferred with MIME type application/pdf: "http://www.beta.anviz.com/myanviz/download/storage/2017/August/week3/629845_Intellisight_User_Manual_EN-1.2.02.pdf".

                //实际情况是我需要让这个地址在手机浏览器中打开:http://www.beta.anviz.com/myanviz/download/storage/2017/August/week3/629845_Intellisight_User_Manual_EN-1.2.02.pdf

            }

        }

    });

}

这是mui的一个例子,我是根据这个例子来写的,mui广告模板,可以跳转它可以从webview跳到手机的浏览器中的,但是我却打不开,请求各位是否可以帮我指点一下,我是哪里写的不对呢?
谢谢!


推荐阅读
author-avatar
Resolve
愿你的生活,既有软肋又有盔甲!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有