对象不支持属性或方法"indexOf" [英] Object doesn't support property or method 'indexOf'
本文介绍了对象不支持属性或方法"indexOf"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码:
<html>
<head>
<title></title>
<script src="jquery-3.2.0.js"></script>
</head>
<body>
<script type="text/javascript">
$(window).load(function () {
alert('Window loaded');
});
$(document).ready(function () {
alert('DOM Loaded and ready');
});
</script>
</body>
</html>
它是如此简单,但我却收到了错误
Its so simple, yet I am getting the error
"Object doesn't support property or method 'indexOf'".
我正在使用Internet Explorer
I am using Internet Explorer
原因是什么?
推荐答案
load
函数在1.8中已被弃用,而在3.0中已被删除.请使用on
方法
The load
function has been deprecated in 1.8 and removed in 3.0. Use the on
method instead
<html>
<head>
<title></title>
<script src="https://code.jquery.com/jquery-3.2.0.min.js"></script>
</head>
<body>
<script>
$(window).on("load",function () {
alert('Window loaded');
});
</script>
</body>
</html>
来自 https://blog.jquery. com/2016/06/09/jquery-3-0-final-released/
已删除不赞成使用的事件别名
Removed deprecated event aliases
.load,.unload和.error.使用.on()注册侦听器.
.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.
这篇关于对象不支持属性或方法"indexOf"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文