facebook ignore javascript events
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!
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('');
}
});
精彩评论