I'm trying to embed a video on my page via a javascript property :
value: "<iframe title='YouTube video player' type=\"text/html\" width='640' height='390 src='http://www.youtube.com/embed/W-Q7RMpINVo'frameborder='0' allowFullScreen></iframe>"
But when I display this value within the browser the text is displayed instead of the youtube video :

You can use two options that are shared here:
use document.write:
var obj = {"video": {
"value": "<iframe title='YouTube video player' type=\"text/html\" width='640' height='390' src='http://www.youtube.com/embed/W-Q7RMpINVo' frameborder='0' allowFullScreen></iframe>"
}}
document.write(obj.video.value);
DEMO
Use Div and append html using jQuery:
var obj = {"video": {
"value": "<iframe title='YouTube video player' type=\"text/html\" width='640'
height='390' src='http://www.youtube.com/embed/W-Q7RMpINVo' frameborder='0'
allowFullScreen></iframe>"
}}
$("#test").html(obj.video.value);
<div id="test"></div>
DEMO
This works for me:
<script>
document.write("<iframe title='YouTube video player' type=\"text/html\" width='640' height='390' src='http://www.youtube.com/embed/W-Q7RMpINVo'frameborder='0' allowFullScreen></iframe>";
</script>
Btw.: You missed a ' caracter after the height='390.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With