不支持Youtube链接

时间:2013-03-11 14:11:09

标签: jquery asp.net html upload

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

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>

1 个答案:

答案 0 :(得分: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>