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 では正常に動作しますが、クロムではエラーが発生します。

"Cannot read property 'LINK_TARGET_BLANK' of undefined"

ラインでlinkTarget : google.feeds.LINK_TARGET_BLANK,

このリンクを読みましたが、解決策はうまくいきませんでした。

次に、この投稿に出くわしました: JavaScript コールバック関数と Google フィード API

しかし、私の場合にこのシナリオを実装する方法がわかりません(Google APIのものは初めてです)。

コードを chrome で動作させるには、どのような変更を行う必要があるか教えてください。

4

1 に答える 1

0

私は解決策を見つけました。

ステートメントを置き換えました

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

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

これは私にとってはうまくいきました。

しかしその後、エラーは「blocked] The page at https://.jsp ran in secure content from http://www.google.com/uds/?file=feeds&v=1&async=2 .」という警告に置き換えられました。

RSS フィードはまだ表示されませんでした。

だから私はクロムアイコンを右クリックし、ターゲットを変更しました

「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 に答える