Hi everyone, I found a ready-made preloader on one site, but it’s all embedded in html, I decided to throw everything on separate files, I managed to throw the styles into a separate css file, and javaScript does not work. What needs to be changed in the script that would work in a separate js include file?
<style type="text/css">#hellopreloader>p{display:none;}#hellopreloader_preload{display: block;position: fixed;z-index: 99999;top: 0;left: 0;width: 100%;height: 100%;min-width: 1000px;background: #86E2D5 url(http://hello-site.ru//main/images/preloads/ball-triangle.svg) center center no-repeat;background-size:98px;}</style> <div id="hellopreloader"><div id="hellopreloader_preload"></div><p><a href="http://hello-site.ru">Hello-Site.ru. Бесплатный конструктор сайтов.</a></p></div> <script type="text/javascript">var hellopreloader = document.getElementById("hellopreloader_preload");function fadeOutnojquery(el){el.style.opacity = 1;var interhellopreloader = setInterval(function(){el.style.opacity = el.style.opacity - 0.05;if (el.style.opacity <=0.05){ clearInterval(interhellopreloader);hellopreloader.style.display = "none";}},16);}window.onload = function(){setTimeout(function(){fadeOutnojquery(hellopreloader);},1000);};</script> var hellopreloader = document.getElementById("hellopreloader_preload"); function fadeOutnojquery(el) { el.style.opacity = 1; var interhellopreloader = setInterval(function() { el.style.opacity = el.style.opacity - 0.03; if (el.style.opacity <= 0.03) { clearInterval(interhellopreloader); hellopreloader.style.display = "none"; } }, 16); } window.onload = function() { setTimeout(function() { fadeOutnojquery(hellopreloader); }, 300); };
<script>. - Igor