1

Setup:
Got a working facebook app and am correctly setup for facebook credits transactions (i.e. everything on the serverside is working fine).
In Firefox and chrome transactions complete without issue, however in IE8 the callback upon completing/closing the purchase dialog throws the following errors:

Error 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

Where the function it points to is:

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 );
},

Specifically highlighting this bit:

FBAS.getSwf().uiResponse( FB.JSON.stringify( response ), method )

in the http://connect.facebook.net/en_US/all.js file

Error 2:
Line: 65 Error: Object doesn't support this action
Object doesn't support this action all.js, line 65 character 2198

[The line it points to is a stupidly long unformatted unreadable mess so I'll omit it unless requested]

Specifically highlighting this bit:

delete d._old_visibility

again in the http://connect.facebook.net/en_US/all.js file

The html I'm using (with the app identifying stuffs removed) is as follows:

<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>

This is just a problem for IE 8 but is stopping the app going live since a significant number of users transactions would fail (or rather would complete, be charged and not take effect due to the failed callback).
For the past few days I've been searching for others with this or a similar problem but to no avail.
I've seen some similar issues where people are warned about javascript variables being created globally and causing interfereance or variables being names using keywords reserved in IE but as far as I can tell neither is the case here. The facebook javascript code is fairly boilerplate stuff lifted from facebook dev pages and reliable sources. It may be JQuery (which I have little experience with), however, again, this is lifted from working examples and if there is a problem I can't see it.

Can anyone help?

DFreeman
  • 542
  • 6
  • 13
  • Updated to jquery 1.7.2. No change. – DFreeman Jul 30 '12 at 14:02
  • Added channelUrl: host+'/channel.html' to FB.init and the channel.html file itself. No change. – DFreeman Jul 30 '12 at 14:08
  • You should remove the comma in `oauth : true,`. See if that fixes your problem. – OptimusCrime Jul 31 '12 at 09:40
  • Hey OptimusCrime, thanks for the tip, unfortunately this isn't the culprit. I've just tried with both the origional FB.init params in the post and with channelUrl ensuring that there's no trailing ',' and it wasn't the source of the problem. – DFreeman Jul 31 '12 at 09:59

2 Answers2

1

SOLVED

I won't accept this answer because I honestly don't think the question was answerable/solvable with the info provided and feel it would be bad form. But I want to leave this here for anyone that might be looking for a solution.

Cause of the error
The problem is the result of the combination of facebook hiding the app during 'normal' facebook actions (in this case, displaying the pay prompt) and external interface calls not working in Internet explorer when the app is hidden/not visible.

Solution
Found at http://flassari.is/2012/02/external-interface-error-object-expected/#comment-1743
All of these steps may not be neccessary but in the end what I did was:

Stop facebook hiding the app by overriding the visibility using

<style>
#[ ID OF THE FLASH OBJECT]
{
    visibility: visible !important;
}
</style>

Adding wmode = "opaque"; to the swfobject params
Using the optional flash_hide_callback by adding hideFlashCallback:"OnHideFlash" to the FB.init options in the actionscript to move/hide the app instead, where OnHideFlash is a javascript function:

function OnHideFlash(params)
{
    if (params.state == 'opened')
    {
        getSwf().style.top = '-10000px';
    } else
    {
        getSwf().style.top = '';
    }
}  

Where getSwf() is your prefered method of getting the flash app object.

Hopefully this will save some people the suffering of pouring through the endless 'reasons that XYXY doesn't work in IE' questions and solutions that has been my last few days.

DFreeman
  • 542
  • 6
  • 13
0

I suggest putting your code through a JavaScript Lint tool and correcting any errors you find. IE8 is extremely picky about how JavaScript is coded, while Firefox and Chrome are ok with minor mistakes. If your code is error free (after linting), it should work properly.

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
  • Thanks for the reply. I'd looked at JSLint before and got the mistaken impression that it was just for .js files which was no good for me. I've now installed JSLint plugin for Notepad++ and am going through the issues it's flagged though I don't think the answer is in there, it's 90% complaints about formatting (e.g. '(' expected on column 52 etc etc). Working though all the issues now though (since as flimsy at it is, I've nothing else left to go on) – DFreeman Jul 30 '12 at 15:27
  • Well, ignoring the formatting warnings and using the following settings in JSLint: /*jslint browser:true*/ /*global $, jQuery, swfobject, FB, top*/ And rearranging the order of a few functions I get no more warnings, so I don't think the problem is here unfortunately. – DFreeman Jul 30 '12 at 15:59
  • Make sure you clear the browers cache to ensure the new (updated) JS is loaded. Might help! – Niraj Shah Aug 01 '12 at 09:57