开发者

facebook ignore javascript events

开发者 https://www.devze.com 2023-01-11 11:25 出处:网络
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.v

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('');
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消