Javascript/SWFobject |创建动态嵌入对象时确定swf对象是否存在 [英] Javascript / SWFobject | Determine if a swf object exists when creating dynamic embed objects

查看:83
本文介绍了Javascript/SWFobject |创建动态嵌入对象时确定swf对象是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建暂时隐藏在选项卡中的SWF对象时,因此在某些浏览器(如FireFox)中未完全加载时,我似乎找不到办法确定SWF是否已加载,因此我可以与之通信它.

When I create SWF objects that are temporarly hidden in tabs, thus not fully loaded in some browsers, like FireFox, I can't seem to find way to figure out if the SWF is loaded or not, so I can communicate with it.

/* Generate SWF (onDocumentReady())*/

swfobject.embedSWF("graph.swf","line-graph-one","100%","250","8","expressInstall.swf",null,null,null,swfRegister);

/* Callback function 
 * -------------------
 * Is triggered when SWF object has done it's job, which is fine, but not a 
 *  suggestion that the SWF is actually loaded by the browser) 
 */

function swfRegister(e){
   console.log(e);
}

这是行不通的.尽管该元素存在于DOM中,但无法以某种方式与其通信.在这种情况下,FireFox尚未加载SWF,因为父容器是隐藏的.(display:none;)

Here is what doesn't work. While the element exists in the DOM, it's not possible to communicate with it somehow. FireFox in this case hasn't loaded the SWF because the parent container is hidden.(display:none;)

document.getElementById('line-graph-one').reloadAll("foobar");

Resulting in: document.getElementById("map-one").reloadAll is not a function

仅当我单击创建SWF的选项卡时,它才起作用.因此,FireFox会加载它.

It only works when I click the tab where the SWF has been created. So FireFox loads it.

我需要一种方法来检查它是否已加载

I need a way to check if it is loaded,

推荐答案

也许先进行可见性检查?

Perhaps a visibility check first?

var $el = $("#map-one");
if ( $el.is(':visible') ) {
  $el[0].reloadAll('foobar');
}

这篇关于Javascript/SWFobject |创建动态嵌入对象时确定swf对象是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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