This is the solution that worked for me (a bit hacked):
First, I wrapped an iframe div named "VideoId" as follows:
<div id="VideoId" style="position: relative; padding: 25px; height: 0;"> <iframe style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;" src="//www.youtube.com/etc..." frameborder="0" allowfullscreen> </iframe> </div>
Then I made this function:
function CloseVideo(){ document.getElementById("VideoId").innerHTML=" "; };
And finally, when closing my Panel button (it was fashionable in my case), I added an oncklick event that calls my function, for example:
<button type="button" class="btn pull-right" onclick="CloseVideo();" data-dismiss="modal">Back</button>
Of course, if you want to call it again, you must replenish the contents of the VideoId with javascript as follows:
document.getElementById("VideoId").innertHTML= '<iframe style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;"+ 'src="//www.youtube.com/etc..."'+ 'frameborder="0"'+ 'allowfullscreen>'+ '</iframe>';
It works great in Chrome, Firefox, IE, and Opera.
PS I tried to remove the div directly from the onclick call, but it continued to report the missing bracket - I don't know why ...
parouden Sep 23 '16 at 12:22 2016-09-23 12:22
source share