可以在页面'标签下的静态FBML中使用javascript吗? [英] Can javascript be used in static FBML under pages' tab?

查看:104
本文介绍了可以在页面'标签下的静态FBML中使用javascript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在静态FBML页面中悬停图像。

I want to hover the image in static FBML page.

但是,即使以下简单的代码也不起作用:

But even the following simple code doesn't work:

<div id="button1">button1</div>
<div id="button2" onmouseover="document.getElementById('button1').setStyle({display: 'none'})">button2</div>


<script type="text/javascript">
    document.getElementById('button1').setStyle({display: 'none'});
</script>

当onmouseover更改为onclick时,它可以正常工作。

When "onmouseover" changes to "onclick", it works.

<div id="button1">button1</div>
<div id="button2" onclick="document.getElementById('button1').setStyle({display: 'none'})">button2</div>


<script type="text/javascript">
    document.getElementById('button1').setStyle({display: 'none'});
</script>

有什么问题吗?

推荐答案

在Facebook FBML应用程序中不允许使用Javascript(它们可能被允许在IFrame应用程序中,但不能确定)。请参阅 http://wiki.developers.facebook.com/index.php/FBJS替代,Facebook JS。

Javascript is not allowed in facebook FBML applications (they may be allowed in IFrame applications but im not certain). See http://wiki.developers.facebook.com/index.php/FBJS for the alternative, Facebook JS.

编辑:
在这种情况下,它将不起作用,因为放置在配置文件框中的JavaScript不会执行,直到第一个用户事件。从FBJS维基:

In this case it will not work as javascript placed in profile boxes is not executed until the first user event. From the FBJS wiki:

在配置文件框中,内联脚本被延迟,直到用户触发第一个活动事件,活动事件被认为是onfocus,基本上任何需要鼠标点击的东西都是一个活动事件,但是在画布页面上,这个例子很好。

"In profile boxes, inline scripts are deferred until the first "active" event is triggered by a user. An active event is considered either onfocus, onclick, onmousedown, and so forth. Basically anything that requires a mouse click is an "active" event. On a canvas page, however, this example works just fine."

这篇关于可以在页面'标签下的静态FBML中使用javascript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆