I am currently working on developing a div element that will prevent a YouTube video embedded in an iframe from playing when clicked. Instead, I want to trigger a JavaScript function upon user interaction. I have added the wmode=opaque parameter to the src attribute as recommended by various online resources. While this solution works seamlessly in Chrome and Firefox, it unfortunately fails to work in IE10.
Below is the code snippet I am using:
<div class="cover" onclick="alert('Working');" style="height: 350px; width: 350px;"></div>
<iframe width="350" height="350" frameborder="0" allowfullscreen="" src="//www.youtube.com/embed/18YA73npI6s?wmode=opaque">
And here is the accompanying CSS:
div.cover {
position: absolute;
z-index: 100;
}
iframe {
z-index: 1;
}
You can view the above code in action here.
If you have any insights on why this workaround does not function properly in IE10, I would greatly appreciate your input.