WeWillFlashYou
WeWillFlashYou

Reputation: 31

How to get the swf object from within a web page?

Suppose the swf file is embeded into the page with the following code:

<object classid="clsid:d27cdb6e-ae6d-11cf-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?

Upvotes: 0

Views: 4460

Answers (4)

1.21 gigawatts
1.21 gigawatts

Reputation: 17756

This is the shortest answer I can write:

var swf = this["mySWF"];

Upvotes: 0

Horia Dragomir
Horia Dragomir

Reputation: 2888

It's easy, but you need to be weary of Internet Explorer

var myFlash = $.browser.msie ? window[ 'myFlash' ] : document[ 'myFlash' ];

Upvotes: -1

hobodave
hobodave

Reputation: 29303

function getMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}

var flash = getMovie('myFlash')

Upvotes: 2

Richard JP Le Guen
Richard JP Le Guen

Reputation: 28753

Does...

var myReference = document.getElementById("myFlash");

... suit your needs? What do you aim to do with this reference once you are done?

Upvotes: 0

Related Questions