Google AJAX Feed API:无法读取属性'LINK_TARGET_BLANK'的定义

Google AJAX Feed API: Cannot read property 'LINK_TARGET_BLANK' of undefined

本文关键字:LINK TARGET 定义 BLANK 属性 API Feed AJAX 读取 Google      更新时间:2023-09-26

我使用以下代码片段(只包含几行)将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上运行良好,但在chrome中它给出了错误:

"Cannot read property 'LINK_TARGET_BLANK' of undefined"

linkTarget : google.feeds.LINK_TARGET_BLANK,

我读了这个链接,但是解决方案不起作用。

然后我看到了这篇文章:JavaScript回调函数和Google Feed API

但我不知道如何实现这个场景在我的情况下(新的谷歌api的东西)。

你能建议需要做什么改变,使代码在chrome工作?

我找到解决办法了。

我替换了语句

google.load('feeds', '1');
google.setOnLoadCallback(LoadDynamicFeedControl);

google.load('feeds', '1', {"callback": LoadDynamicFeedControl});

这对我很有用。

但随后错误被警告所取代"屏蔽了]https://.jsp的页面运行了来自http://www.google.com/uds/?file=feeds&v=1&async=2的不安全内容。"

和RSS源仍然不可见。

所以我右键点击chrome图标,从 修改目标

" C: ' '应用程序数据'谷歌Chrome '程序' ' chrome.exe"

"C:''Application Data'Google'Chrome'Application' Chrome .exe"——allow-running-insecure-content