Internet Explorer recently introduced a new security “feature” into their browser that have had a negative impact on Macromedia Flash objects. The feature blocks Flash interactivity by default instructing the user to “click” on the flash movie to manually activate it. I am sure you will agree with me that this is really annoying! Soon after releasing this feature Microsoft, and then Adobe (together with everyone else who had a half decent knowledge of JavaScript) published scripts to rectify this issue. However they all have negative aspects for those of us who care about web standards such as:
-
You need to put the inline
scriptelement in yourbodyelement -
You should have a
noscripttag to make the flash movie available if JavaScript is turned off -
The scripts use the ugly
document.writemethod
So when I recently faced this issue I wasn’t impressed with the existing solutions at all. I decided to write something better and came up with this simple script. It is a clean DOM script and it doesn’t require any big changes in your HTML code. Just add a unique class name to your flash object (“flash-movie” in my case) and the JavaScript will find and replace it with an object tag that works and Internet Explorer will no longer block it. If JavaScript is turned off through the browser the existing flash object tag will remain the same.
However, bear in mind that I designed this script for a particular site where flash movies are quite simple in terms of communication with JavaScript or each other. This script will make the Flash movies start twice, which may cause some problems for complex flash applications with multiple objects communicating with each other.
var objects = documentgetElementsByTagName"object";
for var i = 0; i < objectslength; i++
if /(^|\s)flash-movie($|\s)/testobjectsiclassName
var width = objectsigetAttribute"width" || 400;
var height = objectsigetAttribute"height" || 300;
var params = objectsigetElementsByTagName"param";
var movie = null;
for var j = 0jj = paramslength; j < jj; j++
if paramsjgetAttribute"name" == "movie"
&& paramsj= objectsi
movie = paramsjgetAttribute"value";
if movie
var f = documentcreateElement"embed";
fsetAttribute"type""application/x-shockwave-flash";
fsetAttribute"src"movie;
fsetAttribute"width"width;
fsetAttribute"height"height;
fsetAttribute"quality""high";
fsetAttribute"pluginspage""http://www.macromedia.com/go/getflashplayer";
objectsiparentNodereplaceChildfobjectsi--;
if windowattachEvent
windowattachEvent"onload"doFlash;
R Walker