javascript - 外部链接 Cordova 不工作

标签 javascript android jquery cordova inappbrowser

使用 codova 开发一个小应用程序 我试图在浏览器上打开链接,但这不起作用 我不知道为什么,它只在 webview.

 <a href='#' onclick='openURL("http://google.com")'/>LInka</a> 
 <a href='#' onclick='window.open("http://google.com", '_system')'/>LInka</a>

    function openURL(urlString){
        myURL = encodeURI(urlString);
        window.open(myURL, '_blank');
    }

最佳答案

我遇到了同样的问题,是否在您的页面上包含了 cordova.js

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
        <title>Hello World</title>
    </head>
    <body>

<a onclick="navigator.app.loadUrl('yourwebsite.com', { openExternal:true });">Links</a>
     <script type="text/javascript" src="cordova.js"></script>   
<script type="text/javascript">
function openURL(urlString){
    myURL = encodeURI(urlString);
    window.open(myURL, '_blank');
}
</script>

尝试创建一个新项目并确保 index.html 看起来像这样 不需要包含 inappbrowser 祝你好运,希望对你有所帮助

关于javascript - 外部链接 Cordova 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23624893/

相关文章:

jquery - 使用 jQuery 更改重叠图像的 z-index

javascript - 我在哪里放置 dom-bind 模板上按钮的监听器方法

javascript - 如何将 Css 实际应用到 wordpress 站点?

java - IllegalArgumentException : expected one element but was: <@com. borisruzanov.social.dependency.scopes.AuthScope,@javax.inject.Singleton>

发送电子邮件后 Android View 为空

javascript - Jquery 检测事件

javascript - jQuery 幻灯片在同一按钮单击中出现和消失

javascript - 使用 jQuery 动态填写表单值

java - 使用 context.getSystemService 找不到 NsdManager

jquery - Twitter Bootstrap 模式对话框