Suppose the swf file is embeded into the page with the following code:
<object classid="clsid:d27cdb6e-ae6d-11开发者_JAVA百科cf-96b8-444553540000" id="myFlash" width="600" height="500">
<param name="movie" value="myMovie.swf">
<embed type="application/x-shockwave-flash" src="myMovie.swf" name="myFlash" width="600" height="500" >
</embed>
</object>
What are the ways to get a reference to the movie with the help of JavaScript?
function getMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
var flash = getMovie('myFlash')
Does...
var myReference = document.getElementById("myFlash");
... suit your needs? What do you aim to do with this reference once you are done?
This is the shortest answer I can write:
var swf = this["mySWF"];
It's easy, but you need to be weary of Internet Explorer
var myFlash = $.browser.msie ? window[ 'myFlash' ] : document[ 'myFlash' ];
精彩评论