Whilst putting together a WordPress image gallery for a new client site I came across the old problem of popup image overlays sitting behind embedded YouTube videos.
Firstly here’s a screenshot of the gallery page in question:
And here’s a screenshot of what happens when you click on one of the images in any version of Internet Explorer:
So what exactly is happening here?
By default YouTube uses an Adobe Flash video player and and the default rendering mode for Flash objects (set by the “wmode” parameter) is “Window” which means it will overlay all other objects on the page, including any popup images. Whilst most modern browsers now handle this scenario properly Internet Explorer still causes the problem shown in the screenshot above.
You can change the z-index of your overlay all you like but it will never sit on top of a Flash object with a “wmode=window” parameter in IE.
This problem can occur with any Flash Object though most web developers avoid using Flash as a development tool these days due to the whole iPhone / iPad compatibility issue. The result is that this is much less likely to be a problem and is also easy to solve by simply giving the Flash Object an additional parameter of “wmode=transparent” or “wmode=transparent”.
Unfortunately when embedded video is delivered from YouTube (or other video streaming sites) you don’t have direct access to the Flash object so simply adding in a new wmode parameter is not a simple option.
OK, now we know the problem, what’s the solutuion?
There are two possible solutions to this problem, the first one uses an HTML5 video player in place of the standard Flash video player and won’t work with versions of Internet Explorer earlier than IE9.
The second method will work in IE6 and up but retains the use of a Flash video player.
Solution 1
This is my preferred solution because it forces YouTube to use the newer HTML5 video player which was created for use on iPhones and iPads which don’t support Flash. Unfortunately this won’t work IE6, IE7 & IE8 as they are not HTML5 compliant.
All you have to do is add
“?html5=1”
to the end of the “src” url in your iframe tag to force YouTube to use it’s HTML5 video player instead of the normal Flash video player.
For example: <iframe src=”http://www.youtube.com/embed/KUDwSz8sDBA?html5=1″ frameborder=”0″ allowfullscreen></iframe>
Solution 2
This method still uses the older Flash video player but will work on older IE browsers from IE6 upwards.
Simply add
“?wmode=transparent”
to the end of the “src” url in your iframe tag to force YouTube to add the “wmode=transparent” parameter to its Flash video player.
For example: <iframe src=”http://www.youtube.com/embed/KUDwSz8sDBA?wmode=transparent” frameborder=”0″ allowfullscreen></iframe>
Solution 3
Fortunately there is also a third option which I discovered by experimenting with adding both parameters to the end of the “src” url as follows:
<iframe src=”http://www.youtube.com/embed/KUDwSz8sDBA?html5=1&wmode=transparent” frameborder=”0″ allowfullscreen></iframe>
What this appears to do is to force YouTube to use the HTML5 video player if the browser supports it, otherwise it will use the Flash video player but apply the “wmode=transparent” parameter to it.
So this Method gives us the best of both worlds, the latest technology where possible and support for older Internet Explorer browsers. And here’s a final screen shot to show the code working in IE9:
For example: <iframe src=”http://www.youtube.com/embed/KUDwSz8sDBA?html5=1″ frameborder=”0″ allowfullscreen></iframe>













