views:

515

answers:

2

Hi,

I have created an fbml application. I have tried numerous examples of fbjs but i am unable to get it working.

I am using this example

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

function do_colors(obj) {
var r = random_int(0, 255), b = random_int(0, 255), g = random_int(0, 255);
obj.setStyle({background: 'rgb('+[r, g, b].join(',')+')',
     color: 'rgb('+[r<128?r+128:r-128, g<128?g+128:g-128, b<128?b+128:b-128].join(',')+')'});
} //-->
 </script>
 <a href="#" id="this" onclick="do_colors(this); return false">Hello World!</a>

When i click on Hello World! it shows following error:

"a210470316064_do_colors is not defined"

Please help me on this

Thanks

A: 

you forget the breakline between } and //--> tag, try:

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

function do_colors(obj) {
var r = random_int(0, 255), b = random_int(0, 255), g = random_int(0, 255);
obj.setStyle({background: 'rgb('+[r, g, b].join(',')+')',
     color: 'rgb('+[r<128?r+128:r-128, g<128?g+128:g-128, b<128?b+128:b-128].join(',')+')'});
}
//-->
 </script>
Angelbit
A: 

Removing resolves the problem.

Pankaj Khurana

related questions