Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support property or method 'indexOf'

Tags:

jquery

I am using the below code:

<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'".

I am using Internet Explorer

What is the reason for it?

like image 726
Abbas Avatar asked Apr 11 '17 06:04

Abbas


1 Answers

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>

From https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

like image 60
raphaëλ Avatar answered Nov 03 '22 14:11

raphaëλ