Question

I am using the following code snippet(only a few lines are included) to include RSS feeds into my application.

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));
  }
};

Code to use above function in my application's 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>

The piece of code works fine on Firefox but in chrome it gives error :

"Cannot read property 'LINK_TARGET_BLANK' of undefined"

at the line linkTarget : google.feeds.LINK_TARGET_BLANK,

I read this link, but the solution did not work.

Then I came across this post: JavaScript Callback Functions and Google Feed API

But I don't know how to implement this scenario in my case (new to google api stuff).

Could you please suggest what changes need to be done to make the code work in chrome?

Was it helpful?

Solution

I found out the solution.

I replaced the statements

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

with

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

This worked for me.

But then the error was replaced by the warning "blocked] The page at https://.jsp ran insecure content from http://www.google.com/uds/?file=feeds&v=1&async=2."

and the RSS feeds were still not visible.

So I right-clicked on chrome icon, modified Target from

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

to

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

And it finally worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top