“对象不支持此属性或方法".在IE 8中执行. [英] "Object doesn't support this property or method" in IE 8. Executes fine in debug

查看:189
本文介绍了“对象不支持此属性或方法".在IE 8中执行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我是不是很愚蠢并且缺少明显的东西,但是:

I don't know if i'm being stupid and missing something obvious but:

我有一个包含以下脚本的页面:

I have a page that has this following script:

$(document).ready(function() {
    $('.fsBtn').click(function(e) {
        $("#fullscreenVideo").show();
        player.stopVideo();
        playerFS.playVideo();
    });
});

在每个浏览器栏中的IE8中,都可以正常加载.但是,在IE8中,调试器将提供: Object doesn't support this property or method Line 144playerFS.playVideo()

In every browser bar IE8 this will load ok. However in IE8 the debugger will come up with: Object doesn't support this property or method Line 144 which is the playerFS.playVideo()

我检查了它是否已声明-已声明.奇怪的是,如果我进入IE的脚本调试器并运行playerFS.playVideo(),它将被IE接受.

I checked that it has been declared -it has. and the odd thing is, if i go into IE's script debugger and run playerFS.playVideo() it will be accepted by IE.

为什么这个脚本不能在代码中执行,但允许我在调试时很好地执行它?

Why would this script not execute in code, yet allow me to execute it fine in debug?

以下是我到目前为止采取的步骤: -将脚本放置在文档中以确保其正常运行. -将脚本放置在页面中,而不是外部JS文件中. -IE调试模式以手动运行脚本.

Here are the steps I've taken so far: - Places the script in a doc ready to ensure that its ok. - Place the script in the page instead of external JS file. - IE Debug mode to run script manually.

任何帮助将不胜感激,这确实使我感到难过.如有必要,可以提供更多信息.

Any help would be appreciated, this really does have me stumped. Can provide more info if necessary.

播放器和playerFS都用以下定义:

Player and playerFS are both defined with this:

function onYouTubePlayerAPIReady() {
    player = new YT.Player('player', {
        height: '360',
        width: '640',
        videoId: V_ID,
        playerVars: playerParams,
        events: {
            // 'onReady': onPlayerReady,
            // 'onStateChange': onPlayerStateChange
        }
    });
    //exact Same code again but for playerFS instead of player
}

其中说玩家"的部分在另一个中是"playerFS".

With the parts where it says "player" being "playerFS" in another .

播放器的HTML页面和JS: http://pastebin.com/ZbBwKg9a

HTML Page and JS for player: http://pastebin.com/ZbBwKg9a

推荐答案

YouTube API很难使用JSAPI嵌入到隐藏的div中.

The youtube API struggles to be embedd in a hidden div using the JSAPI.

在隐藏视频之前,请尝试添加一段初始化视频的代码,以确保正确创建了该视频.

Try to add in a piece of code that initialises the video before hiding it to ensure that it's been created properly.

这篇关于“对象不支持此属性或方法".在IE 8中执行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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