当我创建临时隐藏在选项卡中的SWF对象时,因此在某些浏览器(如FireFox)中没有完全加载,我似乎无法找到是否加载了SWF,因此我可以与之通信它
/* 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;)
document.getElementById('line-graph-one').reloadAll("foobar");
Resulting in: document.getElementById("map-one").reloadAll is not a function
仅当我单击创建SWF的选项卡时才有效。所以FireFox会加载它。
我需要一种方法来检查它是否已加载,
答案 0 :(得分:1)
或许首先进行能见度检查?
var $el = $("#map-one");
if ( $el.is(':visible') ) {
$el[0].reloadAll('foobar');
}