[英]Getting a Flash Movie with Javascript in IE
I have a flash movie that I need to get with javascript. 我有需要使用javascript播放的Flash电影。
Here is how I embed it using swf object : 这是我使用swf对象嵌入它的方式:
<div id="ap1_mod"></div>
<script type="text/javascript">
var flashvars = {
mp3Path: "stop",
artistName : "",
trackName : ""
};
var params = {
codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
src: '/public/flash/ap1_mod.swf',
quality: 'high',
pluginspage: 'http://www.macromedia.com/go/getflashplayer',
scale: 'showall',
devicefont: 'false',
bgcolor: '#999999',
name: 'ap1_mod',
menu: 'true',
allowFullScreen: 'false',
allowScriptAccess:'always', //sameDomain
movie: '/public/flash/ap1_mod.swf',
wmode: "transparent",
allowfullscreen: "true"
};
swfobject.embedSWF("/public/flash/ap1_mod.swf", "ap1_mod", "400", "50", "9.0.0", false, flashvars, params);
</script>
and here is how I try to access it: 这是我尝试访问它的方法:
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
As usual, it's working fine in Firefox and Safari, but it's breaking in IE. 像往常一样,它在Firefox和Safari中工作正常,但在IE中却中断了。 If I add an alert: to display what returns getFlashMovie I get "undefined".
如果添加警报:显示返回getFlashMovie的内容,则会显示“未定义”。
Any idea? 任何想法?
Thanks a lot 非常感谢
According to the documentation, embedSWF replaces the element you specify with the object, so you'd just use: 根据文档,embedSWF用对象替换您指定的元素,因此您只需要使用:
var movie = document.getElementById("ap1_mod");
I haven't actually checked but because the div element is being replaced with an object element, it's possible it isn't re-registered as a property of window in IE. 我实际上没有检查过,但是由于div元素已被object元素替换,因此很有可能没有将其重新注册为IE中window的属性。
Could you specify an id
in the params
and then just use: 您可以在
params
指定一个id
,然后只使用:
document.getElementById( 'theId' );
To reference the <object>
that gets created by swfobject? 要引用由swfobject创建的
<object>
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.