Firefox 8 for Mac存在问题:window.name未定义 [英] Having issue with Firefox 8 for Mac: window.name is undefined

查看:114
本文介绍了Firefox 8 for Mac存在问题:window.name未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用我的网站配置新的Facebook Javascript API,但我遇到了Firefox的问题(与Chrome和Safari完美配合,但尚未完全测试IE,但已被告知没有问题)。

I've been trying to configure the new Facebook Javascript API with my website, but I'm facing an issue with Firefox (working perfectly fine with Chrome and Safari, yet to test out on IE fully but have been informed of no issues).

这个问题正在Facebook的all.js文件的开头指出,消息说

The issue is being pointed out in the beginning of Facebook's all.js file, with the message saying

window.name is undefined
if(!window.FB)window.FB={_apiKey:null,...return document.getElementById(a);}}; 
all.js (line 3)

因此,任何后续使用FB访问SDK 。导致错误说明

Hence, any subsequent accesses to the SDK using FB. results in an error stating

FB is not defined
[Break On This Error] FB.login(function(response) 

我使用的代码是

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
    FB.init({
    appId      : 'my_app_id', // App ID
    channelURL : 'my_channel_file', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    oauth      : true, // enable OAuth 2.0
    xfbml      : true  // parse XFBML
    });
    startLoad();

};

    // Load the SDK Asynchronously
    (function(d){
        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
</script>

有关问题的任何线索?并且之前有没有人遇到过这个错误?

Any clues as to what the issue has? And has anyone faced this error before?

推荐答案

解决了:令人难以置信的是,唯一的小错误就是我在里面使用了一个全局变量我的JS文件名为name。这与Facebook SDK严重禁忌(虽然没有在任何地方提及)。我发现了一个我不记得的链接的推理,但主要问题是全局名称变量被FB api所需的window.name破坏了。

Solved: unbelievably, the only minor error was that I was using a global variable inside my JS file called "name". That's a serious no-no with the Facebook SDK (though not mentioned anywhere). I found the reasoning on a link I can't remember, but the primary issue is that the global name variable is mangled up with the window.name which is required by the FB api.

我建议避免使用名为name的全局变量,无论你是否使用Facebook SDK。以防万一。

I'd simply suggest avoiding a global variable called name whether or not you use the Facebook SDK. Just in case.

这篇关于Firefox 8 for Mac存在问题:window.name未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆