I want to hover the image in static FBML page.
But even the following simple code doesn’t work:
<div id="button1">button1</div>
<div id="button2" onmouseover="document.getElementById('button1').setStyle({display: 'none'})">button2</div>
<script type="text/javascript">
document.getElementById('button1').setStyle({display: 'none'});
</script>
When “onmouseover” changes to “onclick”, it works.
<div id="button1">button1</div>
<div id="button2" onclick="document.getElementById('button1').setStyle({display: 'none'})">button2</div>
<script type="text/javascript">
document.getElementById('button1').setStyle({display: 'none'});
</script>
Is there anything wrong?
Javascript is not allowed in facebook FBML applications (they may be allowed in IFrame applications but im not certain). See http://wiki.developers.facebook.com/index.php/FBJS for the alternative, Facebook JS.
EDIT:
In this case it will not work as javascript placed in profile boxes is not executed until the first user event. From the FBJS wiki:
“In profile boxes, inline scripts are deferred until the first “active” event is triggered by a user. An active event is considered either onfocus, onclick, onmousedown, and so forth. Basically anything that requires a mouse click is an “active” event. On a canvas page, however, this example works just fine.”