问题描述
我已经使用人行横道构建了 PhoneGap 应用程序,当我尝试在其中打开链接时,
i have built a PhoneGap application with crosswalk, and when i try to open a link in it,
- 它不会在同一 webview 中打开,除了会启动浏览器选择窗口.
- it is not opening in the same webview, besides it launch abrowser selection window.
我想要的是,如果我单击到href,它应该将webapp加载到已加载默认index.html的webview中,我也尝试使用js重定向页面.
what i want is if i click to a href it should load the webapp inside the webview that loaded the default index.html, i tried to redirect the page using js too.
我不确定集成是否正确,我只是点击了此链接科多瓦插件
i am not sure i done the integration correct, i just followed this link Codova Plugin
推荐答案
您需要使用 inappbrowser 插件来实现: https://github.com/apache/cordova-plugin-inappbrowser
You need to use inappbrowser plugin to achieve that : https://github.com/apache/cordova-plugin-inappbrowser
通过cordova plugin add cordova-plugin-inappbrowser
安装插件后,您可以编写如下内容:
After installing the plugin via cordova plugin add cordova-plugin-inappbrowser
, you can write somethink like :
<span id="myLink">Load Pap</span>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady()
{
var myLink = document.getElementById('myLink');
myLink.addEventListener("click", function()
{
cordova.InAppBrowser.open('http://192.168.1.11/papa', '_self', 'location=no');
})
}
</script>
这篇关于在自己的手机中打开链接默认的网页视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!