次のコード スニペット (数行のみが含まれています) を使用して、アプリケーションに RSS フィードを含めています。
GFdynamicFeedControl.prototype.parseOptions_ = function(options){
.....
....
this.options = {
....
....
feedCycleTime : GFdynamicFeedControl.DEFAULT_FEED_CYCLE_TIME,
linkTarget : google.feeds.LINK_TARGET_BLANK,
.......
.......
}
}
FdynamicFeedControl.prototype.setup_ = function(container) {
if (container == null) return;
this.nodes.container = container;
// Browser determination code.
....
....
// The feedControl instance for generating entry HTML.
this.feedControl = new google.feeds.FeedControl();
this.feedControl.setLinkTarget(this.options.linkTarget);
// The feeds
this.expected = this.feeds.length;
this.errors = 0;
for (var i = 0; i < this.feeds.length; i++) {
var feed = new google.feeds.Feed(this.feeds[i].url);
feed.setResultFormat(google.feeds.Feed.JSON_FORMAT);
feed.setNumEntries(this.options.numResults);
feed.load(this.bind_(this.feedLoaded_, i));
}
};
アプリケーションの JSP で上記の関数を使用するコード:
<script>
function LoadDynamicFeedControl() {
var feeds = new Array ();
feeds [feeds.length] =
{title: 'RSS feeds',
url: 'hard-coded URL'
};
}
var options = {
stacked : false,
horizontal : false,
title : ""
}
new GFdynamicFeedControl(feeds, 'feed-control', options);
}
// Load the feeds API and set the onload callback.
google.load('feeds', '1');
google.setOnLoadCallback(LoadDynamicFeedControl);
</script>
コードの一部は Firefox では正常に動作しますが、クロムではエラーが発生します。
"Cannot read property 'LINK_TARGET_BLANK' of undefined"
ラインでlinkTarget : google.feeds.LINK_TARGET_BLANK,
このリンクを読みましたが、解決策はうまくいきませんでした。
次に、この投稿に出くわしました: JavaScript コールバック関数と Google フィード API
しかし、私の場合にこのシナリオを実装する方法がわかりません(Google APIのものは初めてです)。
コードを chrome で動作させるには、どのような変更を行う必要があるか教えてください。