views:

25

answers:

1

hi,

I have a fbml app with a contact form and inputs like this one:

<input type="text" tabindex="1" value="Name" name="name" id="name" onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';" /><br />

Does anybody know why facebook ignore this javascript:

onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';"

Thanks!

A: 

FBML apps don't support pure javascript, instead you have to use facebook's own js implementation called FBJS.

Your FBJS should look something like this (not tested):

document.getElementById('name').addEventListener('focus', function(e){ 
    if(document.getElementById('name').getValue() == 'Name') {
        document.getElementById('name').setValue('');
    }
});
serg
thanks serg555, but it doesn't work
Jamland
@Jamland is focus event getting triggered? Do you see any errors?
serg
ok, it seems to work now with addEventListener().Thanks!
Jamland