Wednesday, 15 June 2011

Using Javascript for iFrame src URL -



Using Javascript for iFrame src URL -

i'm playing around youtube api , javascript , can't work. i'm trying utilize javascript give video url iframe. have in body of html page:

<iframe id="ytplayer" type="text/html" width="720" height="405" src="" frameborder="0" allowfullscreen> <script type="text/javascript"> document.getelementbyid("ytplayer").src = "https://www.youtube.com/embed/0rhwc5_iwka?autoplay=1"; </script>

it's trivial illustration can't video player appear. i've looked @ various ways accomplish same result nil works. what's going wrong?

you need close iframe.

<!doctype html> <html> <body> <iframe id="ytplayer" type="text/html" width="720" height="405" src="" frameborder="0" allowfullscreen></iframe> <script type="text/javascript"> document.getelementbyid("ytplayer").src = "https://www.youtube.com/embed/0rhwc5_iwka?autoplay=1"; </script> </body> </html>

javascript url youtube-api getelementbyid src

No comments:

Post a Comment