开发者

Hello world of FBJS

I'm trying to start off using FBJS, and I can't figure this out. The documentation on developer.faceb开发者_如何学Goook.com seems so limited and hard to sort through I can't figure out where to find info on this.

Anyway, I'm just trying to do the hello world application shown on facebook

<script> 
<!-- 
function random_int(lo, hi) { 
   return Math.floor((Math.random() * (hi - lo)) + lo); 
} 

function hello_world(obj) { 
   var r = random_int(0, 255), b = random_int(0, 255), g = random_int(0, 255); 
   var color = r+', '+g+', '+b;
   obj.setStyle('color', 'rgb('+color+')'); 
} 
//--> 
</script>
</head>
<body>
    <a href="#" onclick="hello_world(this); return false;">Hello World!</a>

I keep getting the error saying that the object has no method setStyle. I thought FBJS was supposed to be part of facebook. Do I have to include fbjs in my canvas url?

Oh, and here's the url: http://apps.facebook.com/thedivide/


Your canvas app is in iframe mode. This means you can and should use normal JavaScript. If you want to use FBJS change your application to FBML mode. You can do this from you application setting in the Facebook Integration section. See the attached screenshot:

Hello world of FBJS


Go to the sandbox and it should work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜