Estoy usando el siguiente código:
<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>Es tan simple, pero recibo el error.
"Object doesn't support property or method 'indexOf'".Estoy usando Internet Explorer
¿Cuál es la razón de ello?
La función de load quedó obsoleta en 1.8 y se eliminó en 3.0. Usa el método on su lugar
<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>De https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/
Se eliminaron los alias de eventos obsoletos
.load, .unload y .error, en desuso desde jQuery 1.8, ya no existen. Use .on() para registrar oyentes.
$(window).load(function () { alert('Window loaded'); }); $(document).ready(function () { alert('DOM Loaded and ready'); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>