use*_*084 14 android webview phonegap-plugins cordova phonegap-build
我想知道如何在嵌入webview的app环境中打开一个url.目前这个演示将在外部浏览器中打开一个新选项卡,因此,不是我所期望的.我正在使用google.com进行测试.
总结,我正在寻找一个功能演示.
<?xml version="1.0" encoding="UTF-8"?>
<!-- config.xml reference: https://build.phonegap.com/docs/config-xml -->
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android = "http://schemas.android.com/apk/res/android"
id = "com.xxx.xxxxx"
version = "1.0.0">
<preference name="stay-in-webview" value="true" />
<access origin="*" browserOnly="true" subdomains="true" />
<content src="index.html" />
<allow-navigation href="https://google.com/*" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" version="~1" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<preference name="phonegap-version" value="cli-5.4.1" />
<preference name="permissions" value="none"/>
<preference name="target-device" value="universal"/>
<preference name="fullscreen" value="true"/>
</widget>
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css" />
</head>
<body>
<div>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.location.href = 'https://google.com';
}
</script>
</div>
<script type="text/javascript" src="cordova.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
更新:完整的xml文件:https: //codeshare.io/Vw3Fl
tnt*_*rox 19
尝试:
window.open('https://google.com', '_self ', 'location=yes');
Run Code Online (Sandbox Code Playgroud)
代替 :
window.location.href = 'https://google.com';
Run Code Online (Sandbox Code Playgroud)
这将使用InAppBrowser,并使用_self作为目标.
您必须在config.xml上添加此行以允许导航到外部URL
<allow-navigation href="*" />
Run Code Online (Sandbox Code Playgroud)
这将允许导航到任何外部网址,如果您只是想允许导航到谷歌然后添加此行
<allow-navigation href="https://google.com" />
Run Code Online (Sandbox Code Playgroud)
您可以在插件页面上查看其余文档
https://github.com/apache/cordova-plugin-whitelist
| 归档时间: |
|
| 查看次数: |
21943 次 |
| 最近记录: |