So I have the following javascript function:
function countdown(elementID, pageurl) {
var sec = $("#" + elementID + " span").text() || 0; // Grabs the desired countdown time from the span. elementid is the parent id of the span.
var timer = setInterval(function() {
$("#" + elementID + " span").text(--sec);
if (sec == 0) {
clearInterval(timer);
window.location = pageurl; // Redirects the user to specified url
}
}, 1000);
}
Basically it finds the number in between a span (most likely “3”) and it makes the text “This page will be refreshed in 3…” countdown from 3 to zero, then it sends the user to a specified page.
It works beautifully in FF, but in Safari, it never counts down. In the FF console, I get no syntax errors, but in the safari console, I’m getting a syntax error on line 9.
I’m pulling my hair out and can’t seem to find anything wrong with the code. I’ve even commented out a few lines and still can’t get it to work.