1

我在此页面上使用以下 javascript 来尝试在有人单击视频缩略图时切换视频。

<script>
    function replaceVideo(id) {
      originalSrc = jQuery(" iframe", "#" + id).attr("src");
      autoPlay = originalSrc + "&autoplay=1";
     jQuery(" iframe", "#" + id).attr("src", autoPlay);
      video = jQuery(" .video-content", "#" + id).html();
     jQuery("#video-page-gray-strip #video-page-content").html("");
      jQuery("#video-page-gray-strip #video-page-content").html(video);
      jQuery(" iframe", "#" + id).attr("src", originalSrc);
    }

    jQuery(".video-list li").click(function() {
      id = jQuery(this).attr("id");
      replaceVideo(id);
    });

    jQuery(window).load(function() {
      if(window.location.search.substring(1)) {
            element = window.location.search.substring(1).split('&');
            if (document.getElementById(element[0])) {
                document.onload = replaceVideo(element[0]);
            }
        }
    });
</script>

问题是当我单击缩略图时,视频没有切换,并且出现以下控制台错误:

不安全的 JavaScript 尝试 从 URL http://www.youtube.com/embed/OzOvsDVL_Q8?rel=0的框架访问具有 URL http://mountainfoodstorage.com/index.php/media的框架 。域、协议和端口必须匹配。

我想知道我是否必须更改 JS 来解决这个问题。如果是这样,我该如何解决?

谢谢!

4

0 回答 0