如何使用swfobject使用JavaScript加载swf? [英] How to check if a swf is loaded using JavaScript with swfobject?

查看:187
本文介绍了如何使用swfobject使用JavaScript加载swf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下SWF:

    <head>
    # load js
    <script>
    function graph() {
     swfobject.embedSWF(
     "open-flash-chart.swf", "chart", "400", "180", "9.0.0", "expressInstall.swf",
     {"data-file":"{% url monitor-graph %}"});
        };
    </script></head>

<div id="chart"> </div>
<script>
graph();
</script>

我想只在swf尚未加载的情况下调用图形函数,是否有这样做的方法?谢谢。

I would like to call the graph function only if the swf has not been loaded yet, is there a way to do this? Thanks.

推荐答案

embedSWF 的最后一个参数是一个回调函数在嵌入swf时调用。它接收一个事件对象,其中包含一些表示成功/失败等的属性。有关此内容的更多信息,请参阅 swfobject 文档

The last argument to embedSWF is a callback function that is invoked when the swf has been embedded. It takes in an event object with a couple of properties denoting success/failure, etc. More on this at the swfobject documentation.

swfobject.embedSWF(
 "open-flash-chart.swf", "chart", "400", "180", "9.0.0", "expressInstall.swf",
 {"data-file":"{% url monitor-graph %}"}, {}, {}, 
   function(e) {
     if(e.success) graph();
   }
 );

这篇关于如何使用swfobject使用JavaScript加载swf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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