开发者

Clickable image using Javascript and Facebook graph API

I have this piece of code:

function fbFetch(){
      //Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
      var url = "http://graph.facebook.com/10150171084863204/photos?limit=3&type=small&callback=?";

        //Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
        $.getJSON(url,function(json){
            var html = "<ul>";
            html += '<li><img src="foto.jpg" /></li>';
                //loop through and within data array's retrieve the message variable.
                $.each(j开发者_如何学Cson.data,function(i,fb){

                 html += '<li><img class="fbimg" alt="" src="' + fb.picture + '" /></li>';
                });
            html += '<li><a href=""><img src="fotolain.jpg" border="0" /></a></li>';
            html += "</ul>";


        $('.facebookfeed').html(html);                      



        });

    };

And this image will produce 3 images from the Facebook album. I would like for each image to be clickable and when a user clicks the image, the big image from the Facebook album will be shown.

Now how do I achieve that?


<a href="path-to-your-big-image.jpg"><img src="path-to-your-small-image.jpg"/></a>

simple as this. now you can integrate this idea o anyplace. Whether it be the FB api or somewhere else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜