Reputation: 216
I'm trying to add a simple preloader to my website and I get this error in the console Uncaught TypeError: a.indexOf is not a function
HTML index.html
<html class="js">
<head>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(window).load(function(){
$('#preloader').fadeOut('slow',function(){$(this).remove();});
});
});
</script>
<div id="preloader"></div>
</body>
</html>
CSS style.css
.js div#preloader {
position: fixed;
left: 0;
top: 0;
z-index: 999;
width: 100%;
height: 100%;
overflow: visible;
background: #143441 url('assets/img/loader.gif') no-repeat center center;
}
This only shows a gif that is constantly rotating and after the end of loading..
Upvotes: 3
Views: 12829
Reputation: 216
I searched a little and found a solution. The problem is in .load
event aliase, it needs to be replaced .on
Example:
$(window).load(function(){...});
becomes:
$(window).on('load', function(){ ...});
Upvotes: 8