iframe中的Iframe.可以这样做吗?

Chi*_*keh 6 html javascript iframe jquery vimeo-api

我们有一个视频(vimeo)链接,我们希望我们的用户观看.

每个视频后面都有一个简短的问卷.

我们的目的是在用户点击打开视频进行查看之前,不要让用户看到问卷.

我只能想到将代码嵌入到另一个iframe中只是为了隐藏链接.

这可能吗?

有替代方法吗?

<!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>
Run Code Online (Sandbox Code Playgroud)

pan*_*uli 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');
}
Run Code Online (Sandbox Code Playgroud)

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

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

合理?

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

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