4

我在 ASP.NET MVC 中有一个网站。页面加载后,我收到以下错误。我已经动态传递了 Youtube URL,但出现错误:

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

我的代码:

<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

1 回答 1

5

我认为您使用了错误的 URL,请尝试使用:

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

如果它仍然不起作用,请考虑将视频加载到 aobject而不是 a 中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>
于 2013-03-11T14:59:19.783 回答