简体   繁体   English

使用 Javascript 和 Facebook 图 API 的可点击图像

[英]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(json.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.这张图片会从 Facebook 相册中生成 3 张图片。 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.我希望每张图片都是可点击的,当用户点击图片时,将显示 Facebook 相册中的大图片。

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.无论是 FB api 还是其他地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM