6

We have a video (vimeo) link we would like our users to watch.

Each video is followed by a short questionnaire.

Our intent is to not make the questionnaire visible to the user until the user had clicked open the video for viewing.

I can only think of embedding the code below inside another iframe just to hide the link.

Is this possible?

Is there an alternative approach to this?

<!DOCTYPE HTML>
<html>
<head>
    <meta name="google" value="notranslate" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Dog Smoking</title>

    <style type="text/css">
    body {
        padding-top:0;
        padding-bottom:0;
        padding-left:0;
        padding-right:0;
        margin-top:0;
        margin-bottom:0;
        margin-left:0;
        margin-right:0;
    }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="javascript/froogaloop.js"></script>
    <script src="javascript/froogaloop.min.js"></script>
 <script type="text/javascript">
 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');
 }

 function onPlayProgress(data, id) {
     status.text(data.seconds + 's played');
}
player.addEvent('ready', function() {
    status.text('ready');
    $("#survey_button").show(); // <-- or whatever
});
</script>
</head>
<body>
    <iframe src="http://player.vimeo.com/video/4644119?api=1" width="400" height="375" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
    <a href="http://show.aspx?testid=27#activate"
    target="target-iframe"
    onclick="frames['target-iframe'].document.getElementById('activate')
    .scrollIntoView();return false">Click</a>
</body>
</html>
4

2 回答 2

2

我会为视频使用 JS API,并使用播放器内置的事件回调来使问卷可见。

==更新==

好的 - 所以该链接是如何为播放器合并 JS 控件和回调的分步示例。但是……我们走吧……

第 1 步是在初始嵌入代码后添加“?api=1”。

第 2 步是加载他们的 Froogaloop 库,以便您可以监听事件......

第 3 步是设置一个回调来处理您想收听的任何事件......这个页面上的例子太棒了:

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');
}

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

因此,根据您希望何时显示调查,您可以点击其中之一...

player.addEvent('ready', function() {
    status.text('ready');
    $("#survey_button").show(); // <-- or whatever
});

说得通?

============= 另一个更新 ================

这是一个工作小提琴:http: //jsfiddle.net/QkGRd/10/。您可能想阅读一些关于嵌入资源以及 jsfiddle 如何工作的内容。

于 2014-04-02T18:26:58.167 回答
1

TL;DR 答案

是的,您可以在 iframe 中使用 iframe。尽管就性能而言,这通常不是一个好主意。

于 2017-01-05T20:50:34.383 回答