设置:
有了一个运行良好的facebook应用程序,并正确设置了facebook信用交易(即服务器端的一切都运行良好)。
在Firefox和chrome事务中,没有出现问题,但是在IE8中,完成/关闭购买对话框时的回调会引发以下错误:
错误1:
Line: 52 Error: Object doesn't support this property or method
Object doesn't support this property or method JScript - script block, line 52 character 37
它所指向的函数是:
ui: function( params )
{
obj = FB.JSON.parse( params );
method = obj.method;
cb = function( response ) { FBAS.getSwf().uiResponse( FB.JSON.stringify( response ), method ); }
FB.ui( obj, cb );
},
特别强调这一点:
FBAS.getSwf().uiResponse( FB.JSON.stringify( response ), method )
在US/all.js文件中
错误2:
Line: 65 Error: Object doesn't support this action
Object doesn't support this action all.js, line 65 character 2198
它指向的行是一个愚蠢的、长的、未格式化的、不可读的混乱,因此,除非请求,否则我将省略它。
特别强调这一点:
delete d._old_visibility
再次出现在US/all.js文件中
我使用的html (将应用程序标识删除)如下所示:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Expires" content ="0" />
<meta http-equiv="Pragma" content ="no-cache" />
<meta http-equiv="Cache-Control" content ="no-cache" />
<title>[ APP NAME ]</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
$(document).ready
(
function()
{
var appId = [ APP ID ];
var host = [ APP HOST ];
// If the user did not grant the app authorization go ahead and
// tell them that. Stop code execution.
if (0 <= window.location.href.indexOf ("error_reason"))
{
$(document.body).append ("<p>Authorization denied!</p>");
return;
}
// Loads the Facebook SDK script.
(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));
// When the Facebook SDK script has finished loading init the
// SDK and then get the login status of the user. The status is
// reported in the handler.
window.fbAsyncInit = function()
{
//debugger;
FB.init(
{
appId : appId,
status : true,
cookie : true,
oauth : true,
});
FB.getLoginStatus (onCheckLoginStatus);
};
// Handles the response from getting the user's login status.
// If the user is logged in and the app is authorized go ahead
// and start running the application. If they are not logged in
// then redirect to the auth dialog.
function onCheckLoginStatus (response)
{
if (response.status != "connected")
{
top.location.href = "https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + encodeURIComponent (host+"[ RELATIVE APP PATH ]") + "&scope=publish_stream,user_about_me,read_friendlists,user_photos";
}
else
{
// Start the application
loadGame();
}
}
}
);
function loadGame()
{
var flashvars = {};
var params = {};
var attributes = {};
params.allowscriptaccess = "always";
attributes.id = 'flashContent';
attributes.name = 'flashContent';
swfobject.embedSWF("[ APP SWF ]?"+Math.floor(Math.random()*10000), "flashContent", "100%", "99%", "10.0", null, flashvars, params, attributes);
}
</script>
<div id="flashContent" >
Loading...
</div>
</body>
这只是IE8的一个问题,但由于大量用户事务将失败(或者更确切地说是会完成、充电,并且由于失败的回调而不能生效),所以该应用程序将停止运行。
在过去的几天里,我一直在寻找其他有这个问题或类似问题的人,但没有结果。
我看到了一些类似的问题,在这些问题中,人们被警告说javascript变量在全球范围内被创建,造成了干扰,或者变量是使用IE中保留的关键字命名的,但据我所知,这里的情况都不是这样的。facebook代码是从facebook页面和可靠来源中提取的相当典型的东西。它可能是JQuery (我几乎没有经验),然而,这是从工作的例子,如果有问题,我看不到它。
有人能帮忙吗?
发布于 2012-08-03 16:52:15
解出
我不会接受这个答案,因为老实说,我不认为这个问题可以用提供的信息来回答/解决,而且我觉得这将是糟糕的形式。但我想把这个留给任何想要找到解决办法的人。
错误的原因
这个问题是facebook在“正常”facebook操作期间隐藏应用程序(在本例中显示支付提示)和当应用程序隐藏/不可见时外部接口调用无法在Internet explorer中工作的结果。
溶液
在http://flassari.is/2012/02/external-interface-error-object-expected/#comment-1743发现
所有这些步骤可能不是必要的,但最终我所做的是:
停止facebook隐藏应用程序,方法是使用
<style>
#[ ID OF THE FLASH OBJECT]
{
visibility: visible !important;
}
</style>
向swfobject参数中添加wmode =“非透明”;
使用可选的回调,将hideFlashCallback:" OnHideFlash“添加到actionscript中的FB.init选项中,以移动/隐藏应用程序,其中OnHideFlash是javascript函数:
function OnHideFlash(params)
{
if (params.state == 'opened')
{
getSwf().style.top = '-10000px';
} else
{
getSwf().style.top = '';
}
}
其中getSwf()是获取flash对象的首选方法。
希望这能让一些人免于苦不堪言,因为XYXY在IE的问题和解决方案中没有发挥作用,这是我最近几天的想法。
发布于 2012-07-30 14:58:15
我建议将您的代码放在JavaScript Lint工具中,并纠正您发现的任何错误。IE8对JavaScript的编码方式非常挑剔,而火狐和Chrome对小错误没有问题。如果您的代码是无错误的(在链接之后),它应该正常工作。
https://stackoverflow.com/questions/11720694
复制相似问题