0

Possible Duplicate:
Set Bing background image rss as background of my page jquery

I am a jquery newbie. I need to parse the first image from this RSS feed and use it as the background image for my page. I am developing a phonegap app so cross domain restriction is not an issue.

Here is the rss feed: http://feeds.feedburner.com/bingimages

Community
  • 1
  • 1
Donnie Ibiyemi
  • 971
  • 3
  • 15
  • 26

2 Answers2

2

check this out

Example

You need to add this rss plugin (zrssfeed) in the head of your page to grab the feed

<script type="text/javascript" src="http://www.komfrisk.dk/test/atom/jquery.zrssfeed.js"></script>

Next in your html, put this hidden div.

<div id="RSSview" style='display:none;'></div>

Finally, here is the script to load the first feed and find the image, then set it as the background

    function firstFeed(){
    $('#RSSview').rssfeed( 'http://feeds.feedburner.com/bingimages' , { limit: 1, offset: 0 });
    setTimeout(function(){
    var image = $('.rssMedia').find('a').attr('href');
    $('body').css({'background-image' : 'url("' + image + '")' });
    }, 2000);
}

firstFeed();
VIDesignz
  • 4,703
  • 3
  • 25
  • 37
1

Store the feed value that you want to display in a variable ( parse this fiddle and find the image that you want )

For example var imageUrl = "http://../../myImg.jpg"

Then use this:

$('myOjbect').css('background-image', 'url("' + imageUrl + '")');

Try my fiddle: http://jsfiddle.net/m8GBL/

phemt.latd
  • 1,775
  • 21
  • 33
  • Thanks...the problem is how can i parse the feed with jquery – Donnie Ibiyemi Nov 28 '12 at 15:02
  • I know to do that server side, with jquery i have a cross domain restriction. I don't know if phonegap allow to you to work a web request to this feed and parsing the response. A solution is to use a third part script/proxy. For example yql, this allow you to have a similar sql or linq on a XML/JSON/RSS. If you don't have a server side logic it can be usefull. Try My fiddle: http://jsfiddle.net/m8GBL/1/ – phemt.latd Nov 28 '12 at 15:44