代码工作正常(显示css div背景以及使用javascript获取的新闻)作为单独的html页面但是当用于chrome扩展时,在popup.html中仅显示背景,而不是获取新闻。
google.load("feeds", "1");
var Container=document.getElementById("feed");
var Url="http://www.npr.org/rss/rss.php?";
var Limit=8;
var rssoutput="<h1>Latest NPR feeds:</h1><ul>";
function showFeed(result){
if (!result.error){
var feeds=result.feed.entries;
for (var i=0; i<feeds.length; i++)
rssoutput+="<li><a href='" + feeds[i].link + "'>" + feeds[i].title + "</a></li><br>"
rssoutput+="</ul>";
Container.innerHTML=rssoutput;
}
else
alert("Error fetching feeds!");
}
function startFeed(){
var feeder=new google.feeds.Feed(Url);
feeder.setNumEntries(Limit);
feeder.load(showFeed);
}
window.onload=function(){
startFeed()
}
&#13;
@font-face {
font-family: Exo-Black;
src: url(Exo-Black.otf);
}@font-face {
font-family: LobsterTwo-Regular;
src: url(LobsterTwo-Regular.otf);
}
h1 {
font-family:LobsterTwo-Regular;
color:#3b5998;
margin: 25px;
}
a {
font-family:Exo-Black;
font-size: 1em;
text-decoration:none;
color:#8b9dc3;
}
a:hover {
text-decoration:underline;
color:#3b5998;
background-color:#c9c9ff;
}
ul {
list-style:circle;
margin-left:-15px;
}
div {
width:300px;
height:700px;
border: 8px solid #172631;
background-color: #dfe3ee;
/*
other choices for bg-color eecbff
*/
padding: 8px 10px;
}
&#13;
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<link href="feedStyle.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="feed"></div>
<script type="text/javascript" src="abc.js">
</script>
</body>
</html>
&#13;