【问题标题】:how to use (inAppBrowser) plugin in phonegap project?如何在 phonegap 项目中使用(inAppBrowser)插件?
【发布时间】:2018-10-23 13:07:02
【问题描述】:

我通过这个命令行在我的phonegap项目中安装“inAppBrowser”插件:

cordova plugin add cordova-plugin-inappbrowser

并在 index.html 中写下代码:

<a id="eghdamat_ghabl" href="#" onclick="window.open('http://apache.org', '_blank', 'location=yes'); return false;">click me</a>

但它不会打开链接
config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloWorld</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
	
	<icon src="icon.png" />
	<splash src="splash.png" />
</widget>

【问题讨论】:

    标签: javascript cordova phonegap-plugins phonegap


    【解决方案1】:

    您必须在 config.xml 中添加此行以允许导航到外部 url

    <allow-navigation href="*" />
    

    这将允许导航到任何外部网址。

    如果您只想允许导航到 apache,请添加此行

    <allow-navigation href="https://apache.org" /> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      • 2018-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-21
      相关资源
      最近更新 更多