0

我正在使用以下代码片段(仅包含几行)将 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 Callback Functions and Google Feed API

但我不知道如何在我的案例中实现这个场景(谷歌 API 的新手)。

您能否建议需要进行哪些更改才能使代码在 chrome 中运行?

4

1 回答 1

0

我找到了解决方案。

我替换了陈述

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 图标,修改 Target from

"C:\\Application Data\Google\Chrome\Application\chrome.exe"

"C:\\Application Data\Google\Chrome\Application\chrome.exe" --allow-running-insecure-content

它终于对我有用。

于 2013-06-12T09:07:07.043 回答