You still have the same problem, and a new one. Here's the markup:
HTML Code:
<div id=“preloader” style="display: none; opacity: 0.7;">
New problem - With it's display set to none right in the tag, it will never show unless you do something in javascript or overriding style to change that.
Old problem - it's id still isn't preloader, you still have those messed up word processing quotes around it instead of valid HTML quotes delimiting the id.
It should be:
HTML Code:
<div id="preloader" style="opacity: 0.7;">
See the difference?
On the plus side, your javascript:
Code:
var overlay=document.getElementById('preloader');
window.addEventListener('load', function()
{overlay.style.display = 'none';})
No longer has that problem, however, I see an omission I missed before - the addEventListener function expects a third parameter (true or false):
Code:
var overlay=document.getElementById('preloader');
window.addEventListener('load', function()
{overlay.style.display = 'none';}, false);
I'm not certain if that matters, but I've never seen it without that. Using false is usually fine and what is most customary. I believe it governs whether or not the event can 'bubble' (or in modern parlance 'propagate'), counterintuitively false means it can, which is normal and preferable as it allows other events of the same type on the same object/element to also fire.
Further, even if everything else was right, you cannot set the variable overlay at that point because the element, even with the correct id hasn't been parsed yet. So do it like so:
Code:
window.addEventListener('load', function(){
var overlay = document.getElementById('preloader');
overlay.style.display = 'none';
}, false);
I'd just go direct at that point though:
Code:
window.addEventListener('load', function(){
document.getElementById('preloader').style.display = 'none';
}, false);
Either way, once the window loads the element will have been parsed, so everything should then be fine (assuming I understand what you're trying to do*).
Good luck!
*You do want it to show initially and then disappear when the page loads - right?
Bookmarks