我写了html,使用Google API Feed的JavaScript代码,它在浏览器上100%运行,但在PhoneGap / Android中并不起作用。有没有什么可以让它与PhoneGap一起使用?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="styletable.css">
<title>RSS Feeds Demonstration</title>
<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load("feeds", "1")
</script>
</head>
<body>
<!-- NPR Business RSS URL - http://www.npr.org/rss/rss.php?id=1006 -->
<script type="text/javascript">
/*function lunchboxOpen(lunchID) {
document.getElementById('lunch_' + lunchID).style.display = "block";
document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxClose('" + lunchID + "');\"><img src='close.png' height='50' width='50'/></a>";
}
function lunchboxClose(lunchID) {
document.getElementById('lunch_' + lunchID).style.display = "none";
document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxOpen('" + lunchID + "');\"><img src='open.png' height='50' width='50'/></a>";
}*/
var feedcontainer=document.getElementById("feed");
var feedurl="http://accuratefx.com.lb/index.php/education/news-feed?format=feed&type=rss";
var feedlimit=10;
function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl);
feedpointer.setNumEntries(feedlimit) ;
feedpointer.load(displayfeed) ;
}
//publishedDate
function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries;
var html = thefeeds[0].content;
var re = /<img[^>]+src="http:\/\/([^">]+)/g
var results = re.exec(html);
if(results==null){
source = "img/logo.png";
document.getElementById("img1").src=source;
}
else{
var source = results[1];
source ="http://"+source;
document.getElementById("img1").src=source;
}
var theDiv = document.getElementById("title1");
theDiv.innerHTML += thefeeds[0].title;
var theDiv = document.getElementById("date1");
theDiv.innerHTML += thefeeds[0].publishedDate;
var html = thefeeds[1].content;
var re = /<img[^>]+src="http:\/\/([^">]+)/g
var results = re.exec(html);
if(results==null){
source = "img/logo.png";
document.getElementById("img2").src=source;
}
else{
var source = results[1];
source ="http://"+source;
document.getElementById("img2").src=source;
}
var theDiv = document.getElementById("title2");
theDiv.innerHTML += thefeeds[1].title;
var theDiv = document.getElementById("date2");
theDiv.innerHTML += thefeeds[1].publishedDate;
var html = thefeeds[2].content;
var re = /<img[^>]+src="http:\/\/([^">]+)/g
var results = re.exec(html);
if(results==null){
source = "img/logo.png";
document.getElementById("img3").src=source;
}
else{
var source = results[1];
source ="http://"+source;
document.getElementById("img3").src=source;
}
var theDiv = document.getElementById("title3");
theDiv.innerHTML += thefeeds[2].title;
var theDiv = document.getElementById("date3");
theDiv.innerHTML += thefeeds[2].publishedDate;
.....
我把结果放在表格中并且当我使用Google Chrome和Fire Fox启动它时工作正常。 在PhoneGap中我复制了api的链接。不是在我的PhoneGap项目中,我有一个像link这样的模板,我用菜单和选项购买。 rss feed在选项3中。