views:

1094

answers:

1

I am trying to display a Facebook user's profile picture using XFBML. I am using the following code:

var container = document.getElementById("profilePicture");
var profilePic = new FB.XFBML.ProfilePic(container);
//profilePic.setAttribute("uid", userId);
FB.XFBML.Host.addElement(profilePic);

How do I set the uid attribute of the element? (the commented line does not work)

+2  A: 

Set the attribute before sending it to ProfilePic for processing:

var container = document.getElementById("profilePicture");
container.setAttribute("uid", userId);
var profilePic = new FB.XFBML.ProfilePic(container);
FB.XFBML.Host.addElement(profilePic);