简体   繁体   English

可以在页面标签下的静态FBML中使用JavaScript吗?

[英]Can javascript be used in static FBML under pages' tab?

I want to hover the image in static FBML page. 我想将图像悬停在静态FBML页面中。

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>

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>

Is there anything wrong? 有什么问题吗?

Javascript is not allowed in facebook FBML applications (they may be allowed in IFrame applications but im not certain). Facebook FBML应用程序中不允许使用Javascript(IFrame应用程序中可能允许使用Java,但不确定)。 See http://wiki.developers.facebook.com/index.php/FBJS for the alternative, Facebook JS. 有关替代方法,请参见http://wiki.developers.facebook.com/index.php/FBJS,Facebook JS。

EDIT: In this case it will not work as javascript placed in profile boxes is not executed until the first user event. 编辑:在这种情况下,它将不起作用,因为放置在配置文件框中的javascript直到第一个用户事件才会执行。 From the FBJS wiki: 从FBJS Wiki:

"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." “在配置文件框中,将内联脚本推迟到用户触发第一个“活动”事件之前。活动事件被视为onfocus,onclick,onmousedown等。基本上,所有需要单击鼠标的东西都是“活动”事件。但是,在画布页面上,此示例可以正常工作。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM