There are a couple of problems. First of all, if you're passing an anonymous function to setTimeout
, actually pass a function; don't pass the code for a function inside a string (basically lose the double quotes).
Second, and more importantly, you're calling repeatShowAndHide()
inside of itself, which is essentially infinite recursion. You'd want to call it after the second timeout (for two seconds) has finished.
That said, it might be much simpler to use a single interval of a second that toggles the visibility based on its current value.
var adBottom = document.getElementById('adBottom'),
toggleInterval = setInterval(function() {
adBottom.style.visibility = (adBottom.style.visibility === 'hidden' ? 'visible' : 'hidden');
}, 1000);
Then if you ever want to stop it you'd just need to call clearInterval(toggleInterval);
.