js Google Feed API 호출

2223 단어 JavaScriptnews feeds
인용 하 다.
http://www.techrepublic.com/blog/web-designer/how-to-work-with-rss-using-google-feed-api-and-javascript/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

		<title>New Web Project</title>
	</head>
	<body>
		<h1>RSS Feeds Demonstration</h1>
		<div id="feed"></div>
		<script type="text/javascript" src="http://www.google.com/jsapi"></script>
		<script type="text/javascript">
			google.load("feeds", "1")
		</script>
		<script type="text/javascript">
			var feedcontainer = document.getElementById("feed")
			var feedurl = "http://www.npr.org/rss/rss.php?id=1006"
			var feedlimit = 2
			var rssoutput = "<h2>Latest NPR Business News:</h2><ul>"

			function rssfeedsetup() {
				var feedpointer = new google.feeds.Feed(feedurl)
				feedpointer.setNumEntries(feedlimit)
				feedpointer.load(displayfeed)
			}

			function displayfeed(result) {
				if (!result.error) {
					var thefeeds = result.feed.entries
					for (var i = 0; i < thefeeds.length; i++)
						rssoutput += "<li><a href='" + thefeeds[i].link + "'>" + thefeeds[i].title + "</a></li>"
					rssoutput += "</ul>"
					feedcontainer.innerHTML = rssoutput
				} else
					alert("Error fetching feeds!")
			}


			window.onload = function() {
				rssfeedsetup()
			}
		</script>
	</body>
</html>




좋은 웹페이지 즐겨찾기