Youtube iframe wmode issue
Asked Answered
G

9

136

Using javascript with jQuery, I am adding an iframe with a youtube url to display a video on a website however the embed code that gets loaded in the iframe from youtube doesnt have wmode="Opaque", therefore the modal boxes on the page are shown beneath the youtube video.

Any ideas how to solve the issue?

Gorgon answered 29/10, 2010 at 10:31 Comment(1)
Is this still an issue? I used this solution before but cannot reproduce the original issue in the latest Chrome/Firefox/IE.Standee
H
238

Try adding ?wmode=opaque to the URL or &wmode=opaque if there already is a parameter.

If it doesn't work try this instead, &wmode=transparent which will work in IE browser as well.

Hew answered 18/11, 2010 at 3:6 Comment(8)
nice! works on firefox & chrome but for some reason doesnt work on IE... any ideas ?Niela
try using &wmode=transparent insteadHew
Thank you. This was exactly what I needed. Was unsuccessfully trying to use z-index workarounds.Biradial
I also found that adding <param name="wmode" value="opaque" /> helped meLucerne
The "&amp;wmode=xxxx" setting assumes that you're already passing parameters in the URL. I wasn't in my case, so I instead need to add "?wmode=xxxx" to the URL.Quoth
Differences between opaque and transparent. opaque is supposed to be more performant.Significance
Shabith - "wmode=Opaque" should be "wmode=opaque" (lowercase 'o')Igniter
@Hew This actually fixed an issue for me in Internet Explorer. Adding "?wmode=transparent" to the URL was fixing the issue in everything except all versions of IE. But changing the attribute to your suggested example "&amp;wmode=transparent" fixed the issue in every browser, including all versions of IE. So props to you - your comment should be included in the answer. Because it's spot on and exactly what fixed the issue. Thank you!Spoken
B
81

Try adding ?wmode=transparent to the end of the URL. Worked for me.

Biggin answered 6/12, 2010 at 14:0 Comment(1)
'Transparent' should be the preferred option in my opinion.Sestos
T
18

If you are using the new asynchronous API, you will need to add the parameter like so:

<!-- YOUTUBE -->
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;
var initialVideo = 'ApkM4t9L5jE'; // YOUR YOUTUBE VIDEO ID
function onYouTubePlayerAPIReady() {
    console.log("onYouTubePlayerAPIReady" + initialVideo);
    player = new YT.Player('player', {
      height: '381',
      width: '681',
      wmode: 'transparent', // SECRET SAUCE HERE
      videoId: initialVideo,      
       playerVars: { 'autoplay': 1, 'rel': 0, 'wmode':'transparent' },
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
      }
    });
}

This is based on the google documentation and example here: http://code.google.com/apis/youtube/iframe_api_reference.html

Tomtoma answered 21/2, 2012 at 23:10 Comment(5)
Note that this ALSO needs wmode in playerVars. When it's just under YT.Player, it will only work for the HTML5 player. Adding wmode to playerVars also sends that parameter to the Flash object, which has its own z-order problem. See here: groups.google.com/forum/?fromgroups#!topic/youtube-api-gdata/… I'll edit your answer accordingly.Partridgeberry
I tried this and it did not work. I also did not find any reference to wmode in YouTude documentation.Joacimah
The link changed since I first posted, as did the method for setting the wmode. You can set any flash parameter now or youtube player parameter through playerVars. I have updated the above example.Tomtoma
Loading a entire API just to change a value that can be easily changed in the URL is a total overkill. Don't use this.Bacchanalia
There are some of us who work with the chromeless player and already use the JS API for controlling the UI. For us, this solution totally rocks! ThanksLubra
T
8

Adding ?wmode=opaque to the URL seems to solve this problem for me, although I have not tested it in IE yet.

For those of you having troubles with the previously proposed solution, note that an inital ampersand will only work if you are already supplying other arguments to the URL. The first argument must have an initial question mark: http://www.example.com?first=foo&second=bar

Torrez answered 9/2, 2011 at 0:45 Comment(1)
I was initially getting a black rectangle regardless of the video I was trying to show.. turned out the test machine didn't have flash installed and the dialogue for installing flash was offset too much!Delivery
T
3

Add &amp;wmode=transparent to the url and you're done, tested.

I use that technique in my own wordpress plugin YouTube shortcode

Check its source code if you encounter any issue.

Trunks answered 28/2, 2011 at 11:49 Comment(1)
Adding &amp;wmode=transparent after the you tube URL Solved the problem across all browsers. Thanks for Mr Tubal, Good job :)Older
W
1

Just a tip!--make sure you up the z-index on the element you want to be over the embedded video. I added the wmode querystring, and it still didn't work...until I upped the z-index of the other element. :)

Wilcox answered 17/10, 2012 at 9:3 Comment(0)
H
0

&wmode=opaque didn't work for me (chrome 10) but &amp;wmode=transparent cleared the issue right up.

Helmer answered 29/3, 2011 at 17:25 Comment(0)
J
0

I know this is an old question, but it still comes up in the top searches for this issue so I'm adding a new answer to help those looking for one for IE:

Adding &wmode=opaque to the end of the URL does NOT work in IE 10...

However, adding ?wmode=opaque does the trick!


Found this solution here: http://alamoxie.com/blog/web-design/stop-iframes-covering-site-elements

Jackboot answered 16/8, 2013 at 20:52 Comment(2)
& and ? are both correct depending on which order they are used and which other settings are included in the URL. Obviously ? is used if this is the first (or only) setting, & otherwise.Expeditious
Yes, but IE has special needs. Just try it and see which works in IE 10 and which doesn't. I haven't tried this in IE 11 yet.Jackboot
D
0

recently I saw that sometimes the flash player doesn't recognize &wmode=opaque, istead you should pass &WMode=opaque too (notice the uppercase).

Dentifrice answered 12/10, 2015 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.