facebook登录的FlashContent的GetElementById为null
GetElementById is null for FlashContent for facebook login
我尝试用js-sdk为flash facebook登录创建简单的ExternalInterface机制,但由于GetElementById("flashContent")为null,所以对flash的回调没有运行>>>控制台说。
我该怎么修?我已经在Firefox等中尝试过了,并给出了相同的结果。当我点击按钮时,它会调用checklogin-js,但当进程完成并尝试回调flash时,方法GetElementById(…).onLogin不会运行。
代码:
function requestLogin() {
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
document.getElementById('dua').onLogin();
} else {
console.log('User cancelled login or did not fully authorize.');
document.getElementById('dua').onError();
}
});
}
</script>
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="dua" align="middle">
<param name="movie" value="dua.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<!--[if !IE]>-->
<object id="dua" type="application/x-shockwave-flash" data="dua.swf" width="550" height="400">
<param name="movie" value="dua.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
AS3代码:
import flash.events.DataEvent;
import flash.events.MouseEvent;
flash.system.Security.allowDomain("*");
flash.system.Security.allowInsecureDomain("*");
tombol.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void{
FBconnect();
tombol.removeEventListener(MouseEvent.CLICK, onClick);
}
function FBconnect():void {
teks.text = "masuk fbconnect";
ExternalInterface.call("requestLogin");
ExternalInterface.addCallback("onLogin", onLogin);
ExternalInterface.addCallback("onError", onError);
}
function onError():void {
teks.text = "onError";
trace('error');
}
function logout():void {
ExternalInterface.call("FB.logout", null);
}
function onLogin():void {
teks.text = "onlogin";
trace("FB LOGIN");
connectUser();
}
function connectUser():void {
teks.text = "connectUser";
ExternalInterface.addCallback("loadUser", userCallback);
ExternalInterface.call("connectUser");
}
function userCallback(data:Array):void {
teks.text = "user callback";
trace("FB USER LOADED");
var userData:Object = data[0];
}
我已经找到了这个问题的解决方案。首先,当我尝试用flashContent设置id getelementbyid时,它运行不好。但当我尝试使用id="dua"时,它也没有运行。所以,我用inspect元素来检查它,发现显示的对象是第二个不包含id的对象。所以,我给出了一个id,并在getelementbyid中调用它。所以,当我尝试在任何浏览器中测试它时,它都能很好地运行,但当我试图在IE中测试时,我必须使用IE方法设置getelementbyid。
-CMIIW-
相关文章:
- document.getElementById(..) is null
- global.getElementById('..')为null或不是对象
- 如何处理getElementById返回Null
- Javascript getElementById null error
- 加载时的getelementbyID返回null
- getElementById() null error
- 我的代码给了我一条错误消息:GetElementById()为null或不是对象
- document.getElementById(#mapid) returns null
- JavaScript getElementById returns null
- getElementById不工作返回NULL
- window.opener调用函数给了我一个文档.getElementById(..)为null
- getElementById is null?
- 为什么TypeError:document.getElementById()为null
- GetElementById 在 IE 中返回 null
- getElementById TypeError: “无法将属性'innerHTML'设置为null
- null 返回 by JavaScript 中的 getElementById 方法
- Javascript getElementByID for asp:Image returns null
- Error document.getElementById is null
- getElementById 在 Safari 中返回 null 或 undefined
- Javascript TypeError: document.getElementById(...) is null