polyhedron
polyhedron

Reputation: 1590

Hello world of FBJS

I'm trying to start off using FBJS, and I can't figure this out. The documentation on developer.facebook.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/

Upvotes: 0

Views: 240

Answers (2)

Mika Tuupola
Mika Tuupola

Reputation: 20387

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:

FBML mode

Upvotes: 1

Go to the sandbox and it should work.

Upvotes: 0

Related Questions