gpt4 book ai didi

javascript - YouTube onStateChange 未触发

转载 作者:行者123 更新时间:2023-11-28 08:33:18 26 4
gpt4 key购买 nike

player = new YT.Player(A, {
videoId: z.videoId,
height: z.height,
width: z.width,
playerVars: {
autoplay: (z.autoplay ? 1 : 0),
autohide: (z.autoHide ? 1 : 0),
controls: (z.showControls ? 1 : 0),
loop: (z.loop ? 1 : 0),
rel: (z.showRelated ? 1 : 0),
fs: (z.allowFullScreen ? 1 : 0),
theme: z.theme,
wmode: "transparent"
},
events: {
'onReady': function (event) {alert("onReady")},
'onStateChange': function (event) {alert("onChange")}
}
});

此代码在开发环境中运行良好。在我们的测试服务器上,我们使用 Adob​​e Sitecatalyst 进行跟踪,它也绑定(bind)了 onStateChange。

有人可以建议,如何使多个 onStateChange 工作,或者我可以将此事件绑定(bind)在特定的命名空间中,或任何其他可能的解决方案。

最佳答案

您可以将 Sitecatalyst 绑定(bind)到不同的自定义命名事件,然后在 onStateChange 触发的函数中,您可以分派(dispatch)该自定义事件:

'onStateChange': function (event) {
alert("onChange");
var event = new CustomEvent('siteCatalystOnStateChange', { 'data': event.data }); // here's the event SiteCatalyst will listen for. It's a custom event so you can pass additional parameters; the listener function is passed the object
elem.dispatchEvent(event); // elem is the element that SiteCatalyst is listening on
}

关于javascript - YouTube onStateChange 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21571482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com