使用facebook Javascript-SDK (从服务器异步加载)会产生一种奇怪的效果:
通过SDK成功登录FB后,FB-Logout-Button将按像素从右向左和向后移动。
login/logout-button声明为:
<fb:login-button size="large" autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>在Firebug中停止该脚本会生成一个名为M6XESwM2V2D.js的javascript文件,并出现在以下代码行中:
__d("PluginResize",["Log","UnverifiedXD","bind","copyProperties","curry"],function(a,b,c,d,e,f){var g=b('Log'),h=b('UnverifiedXD'),i=b('bind'),j=b('copyProperties'),k=b('curry');function l(o){o=o||document.body;return o.offsetWidth+o.offsetLeft;}function m(o){o=o||document.body;return o.offsetHeight+o.offsetTop;}function n(o,p,event){this.calcWidth=o||l;this.calcHeight=p||m;this.width=undefined;this.height=undefined;this.event=event||'resize';}j(n.prototype,{resize:function(){var o=this.calcWidth(),p=this.calcHeight();if(o!==this.width||p!==this.height){g.debug('Resizing Plugin: (%s, %s, %s)',o,p,this.event);this.width=o;this.height=p;h.send({type:this.event,width:o,height:p});}return this;},auto:function(o){setInterval(i(this,this.resize),o||250);return this;}});n.auto=function(o,p,event){return new n(k(l,o),k(m,o),event).resize().auto(p);};e.exports=n;});在javascript-debugger中停止代码时,按钮移动会停止(正如预期的那样),继续执行代码会继续移动。在上面打印的javascript-Code中,有一个对setInterval-Method的调用。因此,这可以解释这种行为。但是他们为什么要这样做呢?
我怎样才能停止这个效果?
发布于 2012-07-12 21:00:29
顺便说一下-在登录按钮中添加style="position:fixed;“帮助了我:
<fb:login-button autologoutlink="true" style="position: fixed;"></fb:login-button>干杯,KT。
发布于 2012-07-10 17:12:16
实际上,我的网站上也出现了同样的问题。这似乎是facebook的一个bug。我在以下位置将其作为bug提出:
https://stackoverflow.com/questions/11402525
复制相似问题