不支持Youtube链接

Dot*_*rce 4 html asp.net upload jquery

我在ASP.NET MVC中有一个网站.页面加载后,我收到以下错误.我已动态传递Youtube网址,但收到错误消息:

Load denied by X-Frame-Options: http://www.youtube.com/v/g5RM5StrMXY does not permit cross-origin framing
Run Code Online (Sandbox Code Playgroud)

我的代码:

<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>
Run Code Online (Sandbox Code Playgroud)

Big*_*ood 5

我认为您使用的是错误的网址,请尝试使用:

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

如果它仍然不起作用,请考虑将视频加载到object而不是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>
Run Code Online (Sandbox Code Playgroud)