2014-05-13 63 views
1

工作在一個小應用程序使用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'); 
    } 
+0

可能這會幫助你[我怎樣才能從我的應用程序在Android的Web瀏覽器中打開一個URL?](http://stackoverflow.com/questions/2201917/how-can-i -open-a-url-in-androids-web-browser-from-my-application) – Satpal

+0

@Satpal謝謝我在看這個答案,但我無法理解它 –

+0

我會''_system''上的引用''_system''來代替'apostrophies'。你使用''''''''''封裝了'onclick'事件函數,但'_system''上的第一個自變量結束了封裝。 – benka

回答

1

我有同樣的問題,是包括你自己的網頁上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 祝你好運希望它有幫助

+0

現在已包含在內,但仍然沒有任何內容 –

+0

我編輯我的答案 –