大家好,我在一个网站上找到了一个现成的预加载器,但是它都是嵌入在html中的,我决定把所有东西都放在单独的文件中,我设法把样式放到一个单独的css文件中,而javaScript不起作用。脚本中需要更改哪些内容才能使其在单独的包含的 js 文件中工作?
<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);
};
我怀疑js文件包含在页眉中。