IE中的$(window).load()? [英] $(window).load() in IE?
问题描述
最近我遇到了一个神秘的问题,IE(6-8)一直在给我一个错误。我不知道这是不是问题,但我认为是。
Recently I ran into a mysterious problem that IE (6-8) is keeping throwing me an error. I don't know if this is the problem, but I think it is.
在 jQuery包含网站,输入
$(window).load(function(){
alert("Wont able to see me");
});
并且会弹出一个错误:
无法获取属性'slice'的值:object为null或undefined
"Unable to get value of the property 'slice': object is null or undefined"
我有没有做错什么或其他什么???
Did I do anything wrong, or anything else???
推荐答案
IE10和IE9的最新jQuery(1.7.1)不会产生对我来说这样的错误。
The latest jQuery (1.7.1) with IE10 and IE9 does not produce such an error for me.
作为旁注; 如果您希望在dom准备就绪时执行某些操作;
试试这种方式;
As a side note; If you wish to execute something when the dom is ready; Try this way;
$(function(){
alert("Wont able to see me");
});
我相信这是将函数附加到domready事件的标准约定。
I believe this is the standard convention for attaching a function to domready event.
参考: jQuery文档
这篇关于IE中的$(window).load()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!