Youtube link not supported

I have a website in ASP.NET MVC. After loading the page, I get the error below. I passed the Youtube URL dynamically, but I get an error:

Load denied by X-Frame-Options: http://www.youtube.com/v/g5RM5StrMXY does not permit cross-origin framing 

My code is:

 <script> function closeVideowindow(k) { alert(k); var URL = $('#cnad_text_1').val(); var htm = '<iframe width="100%" height="100%" src=' + URL + '?rel=0 frameborder="0" allowfullscreen ></iframe>'; parent.$('.current').html(htm); parent.$('.current').removeClass('current'); parent.$.fancybox.close(); } </script> <h1>Upload Video</h1> <div class="form_scpop"> <form action="" method="get" name="sizeform"> <!-- <frameset> <iframe src="https://www.youtube.com/watch?v=t090py6b0lM" width="853" height="480"></iframe> </frameset >--> <h2>Insert a youtube video Link</h2> <div class="col2"> <input id="cnad_text_1" name="cnad[text_1]" class="input_txt"> </div> <input name="" type="submit" value="Save" class="saveurl" onclick="closeVideowindow(this)" /> </form> 
+4
source share
1 answer

I think you are using the wrong url, try using:

http://www.youtube.com/embed/g5RM5StrMXY

If it still doesn't work, consider loading the video in an object , not in an iframe :

 <object width="100%" height="100%"> <param name="movie" value="http://www.youtube.com/v/g5RM5StrMXY?hl=en_US&amp;version=3&amp;rel=0"></param><param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/g5RM5StrMXY?hl=en_US&amp;version=3&amp;rel=0" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed> </object> 
+5
source

All Articles