How to fix z-index in YouTube iframes

16 May 2011 by Rick ~ 23 Comments 5807 views

Add a parameter to force YouTube iframe to set a low z-index.

If you have any element you’ll like to show above a YouTube iframe you just have to add a parameter to the iFrame URL.

wmode=transparent

Add the wmode parameter in the src URL.

<iframe class="youtube-player" type="text/html" width="520" height="330" src="http://www.youtube.com/embed/CyLkALroXGc?wmode=transparent" frameborder="0"></iframe>

Subscribe by E-mail:

« »

23 Comments

  1. Well, it doesn’t work on Google Chrome.

     
    • Weird. I’ve tested the code on Firefox 4, Chrome 11, Safari and IE8.

      Everything worked.

      Try to increase the z-index in the element you wanna put over.

      Regards

       
    • It wasn’t working in Chrome for me either, until I added an “&” as follows:

      &wmode=transparent

      or

      src=”http://www.youtube.com/embed/videoseries?list=PL7D65FF0914486CF7&hl=en_US&wmode=transparent”

      Fantastic! Thanks so much, quicoto.

       
  2. Thanks! You just saved me from hours of self torture!

     
  3. Thanks much! Saved me so much time and headaches!

     
  4. Man, I was getting crazy with this f#$ing problem! Thank You!

     
  5. thank you
    great tip

     
  6. Merci, c’est parfait ça fonctionne!

     
  7. $(document).ready(function ()
    {$(’iframe’).each(function()
    {var url = $(this).attr(”src”);
    var result = url.search(/youtube/i);
    if(result!=-1)
    {result = url.indexOf(’?’);
    if(result!=-1)
    {$(this).attr(”src”,url+”&wmode=transparent”);
    } else {$(this).attr(”src”,url+”?wmode=transparent”);}
    }
    });
    });

    /*This will fix z-index for all iframes linked to youtube. Requires jQuery */

     
  8. thanks this code realy work for me i have solved the z-index problem

    Thanks Dude

     
  9. worked great! tried a few others and this really fixed it! thank you

     
  10. Mucho Gracias Amigo!

    Adding

    ?wmode=transparent

    to the YouTube embed URL works like a charm.

    Adding &autoplay=1 to the url makes the video… yep you guessed it, auto play.

     
  11. Thanks! it works all the way. I would like to answer Mr. Edson thanks it’s working properly you can see it here i used here http://amity.edu/ayf on right side video.

    Quicoto thank you so much for your nice post.

    Arjun Kumar (INDIA)

     
  12. Genius might be a bit strong, but saved me a lot time, thanks

     
  13. You can add ?wmode=transparent to the end of the url within the iframe to accomplish the drop-down overlapping the iframe. Worked for me on FF, IE, Chrome and Safari!

     
  14. Great, it works!
    Thanks!

     
  15. It works perfect!!
    Thanks! ;)

     
  16. Hey Todd, many thanks for sharing the wmode solution that worked for you. It worked for mee too!
    Cheers!

     

Add a Comment

Use [code] example piece of code [/code] to insert code into your comment.