External use of JS in FBML - unable to access external script

I am trying to create a small facebook app and link it to a fan page in a tab. I am trying to include an external javascript file in my page and call a method on button click.

Below is some of the code

<script language="Javascript" src="http://mysite.com/fb.js"></script>
<input type="button" value="Click....." onClick="javascript:showDialog();" />

      

fb.js content below

function showDialog() {
    new Dialog().showMessage('Dialog', 'Button clickeed');
}

      

When I load the tab on my fan page the error message "Unable to resolve external script" appears, whereas when I load the canvas url [ http: //apps.facebook.com / ...] and click the button, it works [shows dialog ].

Does the script only turn on the canvas and not the profile page?

I have another question, although I originally had the script src as a relative path, but it got wrong with the same error - "Don't allow external script". Can't I use a relative path for external scripts?

+2


a source to share


2 answers


It is associated with the specific behavior of tabs.

Application tabs are little more than canvases. When the user first navigates to a tab, it is in passive mode. This means that applications cannot autoplay Flash or onload JavaScript. As soon as the user interacts with the tab - clicking on the Flash object, the page becomes active, so it can play Flash, execute JavaScript, etc.



Looks like app tabs, it should be embedded in FBML, not an external resource.

+1


a source


Isn't that a problem? http://developers.facebook.com/docs/fbjs



"Most vendors that allow developers to embed JavaScript in their developers force developers to use IFrames to sandbox their code. Facebook took a different approach to this problem. The JavaScript you give us is parsed and any identifiers (function and variable names) are appended with your application identifier.

0


a source







All Articles