当前位置: 首页 > 工具软件 > InAppBrowser > 使用案例 >

通过inAppBrowser实现浏览网页

陈瀚玥
2023-12-01

1.安装插件

cordova plugin add cordova-plugin-inappbrowser

2.用法

$scope.readWeb = function(){
    var ref = cordova.InAppBrowser.open(url, target, options); //创建新的网页链接
    /*
    Url 为浏览的网页链接
    target :
        _self: 如果url地址在WhiteList中,则用WhiteList将其打开(默认值)
        _blank: 直接在app中将其打开
        _system: 用手机默认浏览器将其打开
    options :
        location: yes or no,设置是否打开插件的locationbar
        hidden:   yes or no,设置加载出页面后是否显示页面
        (Android特有属性)
        zoom:     yes or no,设置是否显示缩放浏览器页面的按钮
        hardwareback: yes or no,设置返回键是否返回前一界面,若否则为退出浏览器页面
        (Ios特有属性)
        closebuttoncaption: yes or no,设置是否显示Done按钮,点击Done按钮可关闭浏览器页面
        toolbar: yes or no,设置是否显示toolbar
        keyboardDisplayRequiresUserAction: yes or no,设置打开键盘时是否通过js调用focus()接收焦点
        toolbarposition: top or bottom,设置工具栏显示在窗口的顶部或底部
    */
    ref.show(); //打开该浏览器对象
    //ref.close(); 关闭该浏览器对象
}

3.官方文档

https://github.com/apache/cordova-plugin-inappbrowser/

 类似资料: