如何添加点击事件到YouTube iFrame [英] How to add tap event to youtube iFrame

查看:147
本文介绍了如何添加点击事件到YouTube iFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



所以这里是我的代码,我添加和初始化YouTube的iframe:

  this.player = {
xtype:'panel',
id:youtubeVideo,
styleHtmlContent:true,
html:'< iframe id =playertype =text / htmlwidth =320height =240src =http://www.youtube.com/embed /'+ youtubeid +'?enablejsapi = 1frameborder =0>< / iframe>',
listeners:{
点击:{
元素:'element' b $ b fn:function(){
alert('hey')
console.log(我想继续在这里的一些事件!!!)
}
}
}
}
this.add([this.player])

正如你可以看到,我试过t o将tap功能附加到面板上,这基本上应该启用一些自定义逻辑。



请问让我知道iframe点击的方法是什么?

解决方案

我的方式是从YouTube .json feed中获取缩略图并将其格式化为dataview .....轻音听众变得容易。如果你想看看如何调用YouTube .json,可以看一下这个例子。



你可以在面板上收听点击,你指定了,这是否工作?



: - )


Having an youtube iFrame, I got very limited control over it in Sencha touch.

So here is my code where I add and initialize youtube iframe:

        this.player = {
            xtype: 'panel',
            id: "youtubeVideo",
            styleHtmlContent : true,
            html: '<iframe id="player" type="text/html" width="320" height="240" src="http://www.youtube.com/embed/' + youtubeid + '?enablejsapi=1" frameborder="0"></iframe>',
            listeners:{
                tap:{
                    element:'element',
                    fn: function () {
                        alert('hey')
                        console.log("I want to proceed with some events in here!!!")
                    }
                }
            }
        }
        this.add([this.player])

And as you can see that I tried to attach tap function to panel, which basically should enable some custom logic.

Could you please let me know what is the solution for listening to the iframe tap?

解决方案

The way I have done it is to grab the thumbnails from the YouTube .json feed and format that into a dataview.....the the tap listeners become easy. Have a look at the o'reilly example if you want to see how YouTube .json is called.

You could listen for a tap on the panel, using that I'd you specified, does that work?

:-)

这篇关于如何添加点击事件到YouTube iFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆