FBML 中的外部 JS 使用 - 无法访问外部脚本
我正在尝试创建一个小型 Facebook 应用程序并将其关联到选项卡中的粉丝页面。我试图在我的页面中包含外部 javascript 文件并调用按钮单击事件的方法。
下面是fb.js的部分代码
<script language="Javascript" src="http://mysite.com/fb.js"></script>
<input type="button" value="Click....." onClick="javascript:showDialog();" />
内容如下
function showDialog() {
new Dialog().showMessage('Dialog', 'Button clickeed');
}
当我加载粉丝页面中的选项卡时,它显示错误“无法允许外部脚本”,而当我加载画布url [http://apps.facebook.com/...]直接点击按钮,就可以了[显示对话框]。
脚本是否只包含在画布上而不是个人资料页面上的作品?
不过我还有另一个问题 最初,我将脚本 src 作为相对路径,但它出错并出现相同的错误 - “无法允许外部脚本”。我不能对外部脚本使用相对路径吗?
I am trying to create a small facebook app and associate 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 a button click event.
Below is a part of the code
<script language="Javascript" src="http://mysite.com/fb.js"></script>
<input type="button" value="Click....." onClick="javascript:showDialog();" />
content of fb.js is as below
function showDialog() {
new Dialog().showMessage('Dialog', 'Button clickeed');
}
When I load the tab in my fan page, it shows an error "Cannot allow external script", whereas when I load the canvas url [http://apps.facebook.com/...] directly and click on the button, it works [shows the dialog].
Does script include works only on the canvas and not on the profile page?
I have another question though
Initially I had the script src as a relative path but it errored out with the same error - "Cannot allow external script". Can't I use relative path for the external scripts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它肯定与应用程序选项卡的特定行为有关。
看起来应用程序选项卡需要嵌入到 FBML 中,而不是外部资源中。
It's bound to be related to the specific behavior of application tabs.
Looks like for application tabs, it needs to be embedded in the FBML and not an external resource.
难道这不是问题吗? http://developers.facebook.com/docs/fbjs
“大多数提供商允许开发者在他们的域中嵌入 JavaScript 迫使开发人员使用 IFrame 来沙箱他们的代码。Facebook 对您提供给我们的 JavaScript 采取了不同的方法,并且任何标识符(函数和变量名称)都会以您的应用程序 ID 开头。”
Could this not be the problem? http://developers.facebook.com/docs/fbjs
"Most providers who allow developers to embed JavaScript within their domain force developers to use IFrames to sandbox their code. Facebook has taken a different approach to this problem. JavaScript that you give us gets parsed, and any identifiers (function and variable names) get prepended with your application ID."