Deleting a window property in IE

I can't find any information on this issue; why doesn't the following code work in IE?

window.x = 45;
delete window.x;
// or delete window['x'];

IE reports an "object doesn't support this action" error. Does it have anything to do with that iterating over window properties in IE issue?


我会这样做:

    window[x] = undefined;
    try{
        delete window[x];
    }catch(e){}


Does this help?

window.x = 45;
alert(window.x);
window.x = null;

I tried this in IE and window.x did have a value, which proves it can be set. Setting the value to null is your best bet for clearing it out.

链接地址: http://www.djcxy.com/p/27220.html

上一篇: 我如何从JavaScript对象中移除一个属性?

下一篇: 在IE中删除一个窗口属性