简体   繁体   English

IE9:对象不支持属性“是”

[英]IE9: Object doesn't support the property “is”

I'm trying to write a little jQuery plugin but I've problems with (of course) Internet Explorer 9. 我正在尝试编写一个小jQuery插件,但是(当然)Internet Explorer 9出现了问题。

This is the code: 这是代码:

$.fn.mytest = $.mytest = function() {
        if ( !! this && this.call && this.apply) {
            self = $("a");
        } else {
            self = this;
        }

    if(self.is(".stupid")) { 
        alert("yes, it's stupid");
    } else{
        alert("no, maybe you are");
    }
    return this;
};

$.mytest();
$("a").mytest();

Fiddle: 小提琴:
http://jsfiddle.net/Abb6a/1/ http://jsfiddle.net/Abb6a/1/

On Google Chrome everything works fine, in IE9 it says that the object does not supports the property or the method "is" . 在Google Chrome浏览器上,一切正常,在IE9中,它表示the object does not supports the property or the method "is"

Looks like IE9 doesn't like the standalone version of my plugin and has troubles with the passed argument this . 看起来IE9不喜欢我的插件的独立版本,并且在传递参数this遇到了麻烦。

How can I solve this trouble? 我该如何解决这个问题?

self is a property of window object, and it's read-only in some versions of IE. selfwindow对象的属性,在某些版本的IE中它是只读的。 To fix the problem, just rename your variable. 要解决此问题,只需重命名变量。 Or if it's purposed to be used in a particular function scope only, you can declare it with var . 或者,如果仅打算在特定的函数范围内使用它,则可以使用var声明它。

Looks like all properties of window referring a window object like top , parent , frames* , self , frameElement* ... are read-only in IE. 看起来,引用诸如topparentframes*selfframeElement*等窗口对象的window所有属性在IE中都是只读的。 Though self can be overridden in IE>9. 虽然可以在IE> 9中覆盖self

* = frames is a HTMLCollection, frameElement refers to HTML(I)frameElement , both of these actually contain window object(s). * = frames是HTMLCollection, frameElement引用HTML(I)frameElement ,这两个实际上都包含窗口对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对象不支持IE9中的属性或方法'append' - Object doesn't support property or method 'append' in IE9 IE9错误:对象不支持属性或方法“ setAttribute” - IE9 error: Object doesn't support property or method 'setAttribute' 对象不支持此属性或方法 -- 在 IE9 中调用 Applet - Object doesn't support this property or method -- Calling an Applet in IE9 TypeError:对象在IE8 / IE9中不支持此属性或方法 - TypeError: Object doesn't support this property or method in IE8 / IE9 对象不支持IE9和IE8中的属性或方法“切换” - Object doesn't support property or method 'Toggle' in IE9 and IE8 ExtJs4 + IE9 = Object不支持属性或方法'createContextualFragment' - ExtJs4 + IE9 = Object doesn't support property or method 'createContextualFragment' SCRIPT438:对象不支持属性或方法“创建”-IE9 - SCRIPT438: Object doesn't support property or method 'create' - IE9 Fineuploader IE9 CORS iframe错误“对象不支持属性或方法'_parseJsonResponse' - Fineuploader IE9 CORS iframe error "object doesn't support property or method '_parseJsonResponse' IE9中的新XMLHttpRequest导致JScript运行时错误:对象不支持此属性或方法 - new XMLHttpRequest in IE9 causes a JScript runtime error: Object doesn't support this property or method IE9-Mime类型不匹配-对象不支持属性 - IE9 - Mime-type mismatch - Object doesn't support property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM