Opera 和 IE7 似乎没有为变量赋值

发布于 2024-12-28 06:54:32 字数 1770 浏览 1 评论 0原文

昨天,我问了一个关于在 YouTube 视频播放后运行脚本以及多次后运行脚本的问题摔跤我想通了

现在,该解决方案适用于 Firefox、Chrome、Safari、IE9 和 IE8,但由于某种原因,它不适用于 Opera 和 IE7。我的 Javascript 经验很少,所以任何帮助将不胜感激。

我像这样链接 JS

<script type='text/javascript' src='http://www.example.ca/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/youtubeapi.js?ver=2011-04-28'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/slidedeck.jquery.lite.js?ver=1.4.5'></script>

youtubeapi.js 中我运行这个

window.YTplayerState;
    function onPlayerStateChange(evt) {
           YTplayerState = evt.data;
    }

window.YTplayerState; 试图帮助修复 Opera/IE7 问题。然后,在 SlideDeck 插件的预先存在的文件中,我运行了

var YTplayerState;
var autoPlay = function() {
    gotoNext = function() {
        if (self.pauseAutoPlay === false) {
            if (self.options.cycle === false && self.current == self.slides.length || YTplayerState == 1) {
                self.pauseAutoPlay = true;
            } else {
                self.next();
            }
            if (YTplayerState == 1) {
                self.pauseAutoPlay = true;
            }
        }
    };

    setInterval(gotoNext, self.options.autoPlayInterval);
};

大多数浏览器似乎都可以接受的文件,尽管这可能只是运气好,但它确实有效。我知道 Opera 中的问题是 YTplayerState 永远不会获取该值,因为如果我使用按键功能手动将值更改为 1,那么一切都会按预期运行。

如果直接提供的代码没有任何问题,那么 Opera 是否有任何我应该注意的常见怪癖?

Yesterday I asked a question about running a script once a YouTube video is playing and after a lot of wrestling I figured this out.

Now the solution works in Firefox, Chrome, Safari, IE9 and IE8 but for some reason it's not working in Opera and IE7. I have very little Javascript experience so any help would be really appreciated.

I link the JS like this

<script type='text/javascript' src='http://www.example.ca/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/youtubeapi.js?ver=2011-04-28'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/slidedeck.jquery.lite.js?ver=1.4.5'></script>

And within youtubeapi.js I run this

window.YTplayerState;
    function onPlayerStateChange(evt) {
           YTplayerState = evt.data;
    }

window.YTplayerState; is an attempt to help fix the Opera/IE7 issue. Then within a pre-existing file for the SlideDeck plugin I run this

var YTplayerState;
var autoPlay = function() {
    gotoNext = function() {
        if (self.pauseAutoPlay === false) {
            if (self.options.cycle === false && self.current == self.slides.length || YTplayerState == 1) {
                self.pauseAutoPlay = true;
            } else {
                self.next();
            }
            if (YTplayerState == 1) {
                self.pauseAutoPlay = true;
            }
        }
    };

    setInterval(gotoNext, self.options.autoPlayInterval);
};

Which most browser seem to be okay with, although that may just be luck, but it works. I know the issue in Opera is that YTplayerState never gets the value because if I manually change the value to one with a keypress function then it all behaves as expected.

If it's not anything with the code directly provided, are there any common quirks with Opera that I should look out for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不即不离 2025-01-04 06:54:32

据我所知,这是 Youtube 视频播放器中的一个错误。对不起。

如果您搜索“onPlayerStateChange opera”,您会发现更多类似的错误报告。

To my knowledge, this is a bug in Youtube video player. Sorry.

If you google for "onPlayerStateChange opera", you'll find more similar error reports.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文