Javascript 全屏vimeo视频播放后如何重定向URL?

Javascript 全屏vimeo视频播放后如何重定向URL?,javascript,html,url,redirect,vimeo,Javascript,Html,Url,Redirect,Vimeo,我读过这个话题,但似乎还没有得到回答 我有一个vimeo全屏视频。我想页面重定向到一个外部网站(如google.com)后,它完成播放。我该怎么做?感谢您的帮助。下面是JSFIDLE和代码:' HTML <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"> </script> <script src="https://cdnjs.cloudflare.

我读过这个话题,但似乎还没有得到回答

我有一个vimeo全屏视频。我想页面重定向到一个外部网站(如google.com)后,它完成播放。我该怎么做?感谢您的帮助。下面是JSFIDLE和代码:'

HTML
<script 
src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js">
</script>
<script 
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>

<!-- Youtube or Vimeo Embed code here - add 'fullvid' class -->
<iframe class="fullvid" id="vim" width="1280" height="720" 
src="https://player.vimeo.com/video/213039819?
api=1&autoplay=1&loop=0&badge=0title=0&byline=0&portrait=0&background=0" 
frameborder="0" allowfullscreen></iframe>

CSS
<style type="text/css">
.vidcover {
background: #000;
opacity: 0.4;
display: block;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: -1;
-webkit-transition: opacity 800ms ease 0.2s;
-moz-transition: opacity 800ms ease 0.2s;
-ms-transition: opacity 800ms ease 0.2s;
transition: opacity 800ms ease 0.2s;
}
.fullvid {
width: 1280px;
height: 720px;
position: fixed;
bottom: 50%;
left: 50%;
z-index: -2;
-webkit-transform: translate(-50%, 50%);
-moz-transform: translate(-50%, 50%);
-ms-transform: translate(-50%, 50%);
transform: translate(-50%, 50%);
-webkit-transition: all 400ms ease-out 400ms;
-moz-transition: all 400ms ease-out 400ms;
-ms-transition: all 400ms ease-out 400ms;
transition: all 400ms ease-out 400ms;
}
/* Optional: For demo purpose only*/
* {
margin: 0;
padding: 0;
}
html {
font-size: 62.5%;
}
body {
color: #222;
font: 1.3rem/1.4em Arial, Sans-serif;
margin: 0;
}
h1 { 
color: #000;
line-height: 1.3em;
font-size: 4rem;
text-transform: uppercase;
letter-spacing: 0.01em;
}
h2 {
font-size: 2.4rem;
font-weight: normal;
color: #666;
text-transform: uppercase;
letter-spacing: 0.02em
}
p {
margin-bottom: 2rem;
}
.credits {
font-size: 1rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: #888;
margin-top: 4rem;
}
article {
max-width: 320px;
background: rgba(255,255,255,0.95);
padding: 4rem 4rem 0.1rem;
margin: 0rem;
border-left: 0rem solid #888;
}
</style>

JS
<script type="text/javascript">
/**
* @name jQuery fullvid
* @author M'c kenneth Licon
* @link http://mlicon.ca
* @version 1.0.0
*/

$(document).ready(function() {
  $('body')
    .prepend('<div class="vidcover"></div>')
    .hover (
        function() {
            $('.vidcover').css({'opacity':'0.4'})
        },
        function() {
            $('.vidcover').css({'opacity':'0'})
        }
    );

    $(window).resize( function(){
        var theWidth = $(window).width();
        var theHeight = $(window).height();
        var newWidth = (theHeight*1.77777778);
        var newHeight = (theWidth/1.77777778);

        if ( (theWidth > 1280) && (newHeight > theHeight )) {
            $('.fullvid').css({'width':theWidth, 'height':newHeight});
        }

        if ( (theHeight > 720) && (newWidth > theWidth )) {
            $('.fullvid').css({'height':theHeight, 'width':newWidth});
        }

        $('.vidcover').css({'height':theHeight, 'width':theWidth});
    }).resize();
});

/*REDIRECT URL PORTION STARTS HERE*/
    function playVideo() {
    var video= document.getElementById('vim');
    video.play();
    video.addEventListener('ended',function() {
        window.location= 'http://www.google.com';
    });
}
playVideo();
</script>
HTML
CSS
.维德封面{
背景:#000;
不透明度:0.4;
显示:块;
宽度:100%;
身高:100%;
位置:固定;
排名:0;
左:0;
z指数:-1;
-webkit转换:不透明度800ms,轻松0.2s;
-moz转换:不透明度800ms,降低0.2s;
-ms转换:不透明度800ms缓解0.2s;
过渡:不透明度800ms缓解0.2s;
}
富尔维德先生{
宽度:1280px;
高度:720px;
位置:固定;
底部:50%;
左:50%;
z指数:-2;
-webkit转换:翻译(-50%,50%);
-moz变换:平移(-50%,50%);
-ms转换:翻译(-50%,50%);
转换:翻译(-50%,50%);
-webkit过渡:所有400ms的缓变为400ms;
-moz转换:所有400ms均放松400ms;
-毫秒转换:所有400ms都将在400ms内释放;
过渡:所有400ms缓解400ms;
}
/*可选:仅用于演示目的*/
* {
保证金:0;
填充:0;
}
html{
字体大小:62.5%;
}
身体{
颜色:#222;
字体:1.3rem/1.4em Arial,无衬线;
保证金:0;
}
h1{
颜色:#000;
线高:1.3em;
字号:4rem;
文本转换:大写;
字母间距:0.01em;
}
氢{
字体大小:2.4rem;
字体大小:正常;
颜色:#666;
文本转换:大写;
字母间距:0.02em
}
p{
边缘底部:2rem;
}
.学分{
字号:1rem;
文本转换:大写;
字母间距:0.06em;
颜色:#888;
边缘顶部:4rem;
}
文章{
最大宽度:320px;
背景:rgba(255255,0.95);
填充:4rem 4rem 0.1rem;
保证金:0雷姆;
左边框:0rem实心#888;
}
JS
/**
*@name jQuery fullvid
*@作者M'c kenneth Licon
*@linkhttp://mlicon.ca
*@version 1.0.0
*/
$(文档).ready(函数(){
$(“正文”)
.prepend(“”)
.悬停(
函数(){
$('.vidcover').css({'opacity':'0.4'})
},
函数(){
$('.vidcover').css({'opacity':'0'})
}
);
$(窗口)。调整大小(函数(){
var theWidth=$(window.width();
var theHeight=$(window.height();
var newWidth=(高度*1.777 8);
var newHeight=(宽度/1.777 8);
如果((宽度>1280)和(&(新高度>高度)){
$('.fullvid').css({'width':theWidth,'height':newHeight});
}
如果((高度>720)和(&(新宽度>宽度)){
$('.fullvid').css({'height':theHeight,'width':newWidth});
}
$('.vidcover').css({'height':theHeight,'width':theWidth});
}).resize();
});
/*重定向URL部分从这里开始*/
函数playVideo(){
var video=document.getElementById('vim');
video.play();
video.addEventListener('end',function(){
窗口位置http://www.google.com';
});
}
播放视频();

这把小提琴也许能帮助你。请注意,他们正在使用名为froogaloop的插件添加事件侦听器


嘿,谢谢你的反馈,我已经添加了侦听器,但它仍然不会重定向网站。我错过什么了吗?
var iframe = $('#player1')[0],
    player = $f(iframe),
    status = $('.status');

// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
    status.text('ready');

    player.addEvent('pause', onPause);
    player.addEvent('finish', onFinish);
    player.addEvent('playProgress', onPlayProgress);
});

// Call the API when a button is pressed
$('button').bind('click', function() {
    player.api($(this).text().toLowerCase());
});

function onPause(id) {
    status.text('paused');
}

function onFinish(id) {
   // status.text('finished');
   window.location = 'http://www.google.com';
}

function onPlayProgress(data, id) {
    status.text(data.seconds + 's played');
}