user1142872
user1142872

Reputation: 107

How to Play a Flash Movie with JavaScript in Firefox

I have found a way to send a play(); command to my Flash movie in IE9 but I can't figure it out in Firefox9. Here is the code I am using that works in IE:

<head>
<script language="JavaScript">
<!--
function startFlash()
{
document.getElementById("movie").Play();
}
-->
</script>
</head>
<body onLoad="startFlash()">

...

<object... id="movie">
<embed... name="movie">

...

I tried using: window.document["movie"].Play();

no luck. Any ideas? I could care less about Safari and Chrome for now, but I have gotta have Firefox compatibility! Thanks.

Upvotes: 0

Views: 2836

Answers (1)

Kodiak
Kodiak

Reputation: 5978

Adobe recommends this code:

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

Upvotes: 1

Related Questions