I have a div with a Youtube video embedded via iframe.
-
Finally I got the solution.
I don't know which server side language you are using, I'm using PHP. Anyway find if the browser is IE9 then use object tag.
if (preg_match('/MSIE 9.0/', $_SERVER['HTTP_USER_AGENT'])) { /*for IE 9.0 generate with objace tag*/ ?>
<object type="application/x-shockwave-flash" data="VIDEO_URL">
<param name="movie" value="VIDEO_URL" />
</object>
<?php } else { /*rest of all browsers,in iframe*/ ?>
<iframe src="VIDEO_URL"></iframe>
<?php } ?>
In short use object
tag for IE9 and iframe
for rest.
讨论(0)
-
If you still want to continue using the iframe code, you can remove the iframe src by calling removeAttr (instead of trying to set it to blank).
$('#video iframe').removeAttr('src')
讨论(0)
-
I got the solution.
ytplayer.getIframe().src='';
讨论(0)
-
I was receiving the same error and came to my own solution. I felt that using the old "object" solution for IE9/IE10 was not a true solution because you should never have to code specifically for one browser.
The difference in my situation, I simply needed a video to pop-up, and then stop playing and disappear when close button was clicked.
Using your provided code...
function playVideo() {
$('#video iframe').attr('src', 'http://www.youtube.com/embed/VIDEO_ID_HERE');
$('#video iframe').fadeIn();
}
function stopVideo() {
$('#video iframe').attr('src', '');
$('#video').fadeOut();
}
讨论(0)