Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Cordova RSS源链接将不会在外部浏览器中打开_Javascript_Android_Ios_Cordova_Rss - Fatal编程技术网

Javascript Cordova RSS源链接将不会在外部浏览器中打开

Javascript Cordova RSS源链接将不会在外部浏览器中打开,javascript,android,ios,cordova,rss,Javascript,Android,Ios,Cordova,Rss,我已经使用Intel XDK开发了一个Cordova应用程序。它是一个选项卡式视图RSS聚合器,使用GoogleFeedAPI并使用一个自定义插件简化RSS检索。我遇到了一个问题,我希望RSS提要链接在外部/系统浏览器中打开,而不是在应用程序的webview中打开,但我还没有找到一种有效的方法。我尝试了论坛中建议的几乎所有方法(包括、、和),但都没有成功。不管怎样,当我点击一个链接时,“加载内容”动画就会出现,在Android和iOS中都不会发生任何事情(实际上,应用程序会被卡住)。我确实安装了

我已经使用Intel XDK开发了一个Cordova应用程序。它是一个选项卡式视图RSS聚合器,使用GoogleFeedAPI并使用一个自定义插件简化RSS检索。我遇到了一个问题,我希望RSS提要链接在外部/系统浏览器中打开,而不是在应用程序的webview中打开,但我还没有找到一种有效的方法。我尝试了论坛中建议的几乎所有方法(包括、、和),但都没有成功。不管怎样,当我点击一个链接时,“加载内容”动画就会出现,在Android和iOS中都不会发生任何事情(实际上,应用程序会被卡住)。我确实安装了InAppBrowser,并尝试在配置中提供对导航、意图和访问的完全访问权限,但到目前为止没有任何效果。有人能帮我弄清楚这是否与GoogleFeedAPI有关吗

这是我的index.html-

<!DOCTYPE html>
    <!--HTML5 doctype-->
    <html>

    <head>

    <title>RSSAgreggator</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,   maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <style type="text/css">
    #feeds { font-size: medium; font-family: helvetica; 
    border-left: 1px solid #ddd}

    .gfc-control .gfc-resultsHeader .gfc-title { font-size: small; font-weight: bold; color: white}
    .gfc-control div { font-family: helvetica }

    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


    <script type="text/javascript" src="http://www.google.com/jsapi"></script>

    <link rel="stylesheet" type="text/css" href="lib/appframework/icons.css" />
    <link rel="stylesheet" type="text/css" href="lib/appframework/af.ui.css" />

    <script type="text/javascript" charset="utf-8" src="lib/jquery.min.js">   </script>
    <script type="text/javascript" charset="utf-8" src="lib/appframework/appframework.ui.min.js"></script>  

    <script src='cordova.js'></script>
    <script type="text/javascript" charset="utf-8" src="lib/app.js"></script>
    <script type="text/javascript" charset="utf-8" src="lib/jquery.gfeed.js"></script>   

    <script type="text/javascript">
        $(function() {
            // convert anchors
            $('a.feed').gFeed( { target: '#feeds', tabs: true, max: 100 });

        });


        </script>

</head>

<body>

    <div id="splashscreen" class='ui-loader heavy'>
        App Framework - Tab View
        <br>
        <br>
        <span class='ui-icon ui-icon-loading spin'></span>
        <h1>Starting app</h1>
    </div>

    <div class="view">
        <header>
            <h1>RSSAggregator</h1>
        </header>

        <div class="pages">

            <div class="panel" data-title="Aggregator" id="tab1" >
                <div id="feeds"> 
                    <a class="feed" href="http://feeds.feedburner.com/thr/news">THR</a> 
                    <a class="feed" href="http://feeds.feedburner.com/variety/headlines">Var</a>

            </div>

            <div class="panel" data-title="Tags" id="tab2" >
                This is view for second Tab
            </div>

            <div class="panel" data-title="Feeds" id="tab3">
                This is view for third Tab
            </div>

            <div class="panel" data-title="Settings" id="tab4">
                This is view for fourth Tab
            </div>

        </div>
    <!--
     <footer>
            <a href="#tab1" class="icon home" onclick="$.afui.clearHistory()">Home</a>
            <a href="#tab2" class="icon heart" onclick="$.afui.clearHistory()">Tags</a>
            <a href="#tab3" class="icon message" onclick="$.afui.clearHistory()">Feeds</a>
            <a href="#tab4" class="icon user" onclick="$.afui.clearHistory()">Settings</a>
        </footer>



    </div>
    -->

    </body>

    </html>
这是应用程序本身的编码:

function myGetElementsByClassName(selector) {
    if ( document.getElementsByClassName ) {
        return document.getElementsByClassName(selector);
    }

    var returnList = new Array();
    var nodes = document.getElementsByTagName('div');
    var max = nodes.length;
    for ( var i = 0; i < max; i++ ) {
        if ( nodes[i].className == selector ) {
            returnList[returnList.length] = nodes[i];
        }
    }
    return returnList;
}

var rssReader = {
    containers : null,

    // initialization function
    init : function(selector) {
        containers = myGetElementsByClassName(selector);
        for(i=0;i<containers.length;i++){
            // getting necessary variables
            var rssUrl = containers[i].getAttribute('rss_url');
            var num = containers[i].getAttribute('rss_num');
            var id = containers[i].getAttribute('id');

            // creating temp scripts which will help us to transform XML (RSS) to JSON
            var url = encodeURIComponent(rssUrl);
            var googUrl = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+num+'&q='+url+'&callback=rssReader.parse&context='+id;

            var script = document.createElement('script');
            script.setAttribute('type','text/javascript');
            script.setAttribute('charset','utf-8');
            script.setAttribute('src',googUrl);
            containers[i].appendChild(script);
        }
    },

    // parsing of results by google
    parse : function(context, data) {
        var container = document.getElementById(context);
        container.innerHTML = '';

        // creating list of elements
        var mainList = document.createElement('ul');

        // also creating its childs (subitems)
        var entries = data.feed.entries;
        for (var i=0; i<entries.length; i++) {
            var listItem = document.createElement('li');
            var title = entries[i].title;
            var contentSnippet = entries[i].contentSnippet;
            var contentSnippetText = document.createTextNode(contentSnippet);

            var link = document.createElement('a');
            link.setAttribute('href', entries[i].link);
            link.setAttribute('target','_system');
            var text = document.createTextNode(title);
            link.appendChild(text);

            // add link to list item
            listItem.appendChild(link);

            var desc = document.createElement('p');
            desc.appendChild(contentSnippetText);

            // add description to list item
            listItem.appendChild(desc);

            if (entries[i].mediaGroups) {
                var img = new Image();
                img.src = entries[i].mediaGroups[0].contents[0].url;
                listItem.appendChild(img);
            }

            // adding list item to main list
            mainList.appendChild(listItem);
        }
        container.appendChild(mainList);
    }
};

window.onload = function() {
    rssReader.init('post_results');
}
函数MyGetElementsByCassName(选择器){
if(document.getElementsByClassName){
返回文档.getElementsByCassName(选择器);
}
var returnList=新数组();
var nodes=document.getElementsByTagName('div');
var max=nodes.length;
对于(变量i=0;i
找到了解决方案!只需注释掉以下部分:

        link.setAttribute('href', entries[i].link);
        link.setAttribute('target','_system');
然后添加一个机制来捕获链接上的所有点击并打开它们

<?xml version='1.0' encoding='UTF-8'?>

<!--This file is generated by the Intel XDK. Do not edit this file as your edits will be lost.           -->
<!--To change the contents of this file, see the documentation on the intelxdk.config.additions.xml file.-->
<intelxdk:version value="1.0"/>
<intelxdk:cordova-cli version="5.4.1"/>

<content src="index.html"/>
<access origin="*"/>
<allow-intent href="*"/>

<intelxdk:plugin intelxdk:name="Device" intelxdk:value="cordova-plugin-device" intelxdk:version="1.1.1" intelxdk:checksum="927290ca" intelxdk:type="file"/>
<intelxdk:plugin intelxdk:name="Splashscreen" intelxdk:value="cordova-plugin-splashscreen" intelxdk:version="3.2.0" intelxdk:checksum="452a4659" intelxdk:type="file"/>
<intelxdk:plugin intelxdk:name="InAppBrowser" intelxdk:value="cordova-plugin-inappbrowser" intelxdk:version="1.3.0" intelxdk:checksum="20f7ee20" intelxdk:type="file"/>
<intelxdk:plugin intelxdk:name="Cordova Network Whitelist Plugin (added by Intel XDK)" intelxdk:value="cordova-plugin-whitelist" intelxdk:version="1.2.1"/>
<preference name="android-minSdkVersion" value="14"/>
<preference name="android-targetSdkVersion" value="21"/>
<preference name="android-installLocation" value="auto"/>
<preference name="android-signed" value="true"/>
<preference name="Fullscreen" value="true"/>
<preference name="splashscreen" value="splash"/>
<!--creationInfo:{"src":"jsapp/template-tab-view-js/sample.zip","projectTypeName":"com.intel.xdk.projecttype.jsapp"}-->
<preference name="debuggable" value="false"/>
<platform name="ios">
    <!-- below requires the splash screen plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
    <preference name="AutoHideSplashScreen" value="true"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="2"/>
    <preference name="ShowSplashScreenSpinner" value="false"/>

    <!-- below requires the status bar plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-statusbar -->
    <!-- see http://devgirl.org/2014/07/31/phonegap-developers-guid -->
    <preference name="StatusBarOverlaysWebView" value="false"/>
    <preference name="StatusBarBackgroundColor" value="#000000"/>
    <preference name="StatusBarStyle" value="lightcontent"/>
</platform>
<platform name="android">
    <!-- below requires the splash screen plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
    <preference name="SplashMaintainAspectRatio" value="false"/>
</platform>
<intelxdk:crosswalk xmlns:intelxdk="http://xdk.intel.com/ns/v1" xwalk-command-line="--disable-pull-to-refresh-effect"/>
<intelxdk:crosswalk xmlns:intelxdk="http://xdk.intel.com/ns/v1" xwalk-command-line="--ignore-gpu-blacklist"/></widget>
        link.setAttribute('href', entries[i].link);
        link.setAttribute('target','_system');