On a little website I made- click here if you want to see it.
Anyway, using jQuery, when you scroll down, you are yanked back up, the top text changes, and one variable increases. Depending on the value of the variable, the text at the top changes accordingly. The problem here is that the number doesn't change further. It only shows the first text, which is if the variable is equal to one, but does not exceed further. Here is the code with a few notes to express what I mean.
FUN = 0; //Does not have "var" so it can be global to the following function
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
FUN++; //Adds one to FUN variable.
if(FUN==1){ //This stuff here executes just fine.
scream.playclip(); //This also works too; don't worry.
$("#text").replaceWith( "<h1>You should not have done that.</h1><br><img src='sck1.jpg'>" );
} else if(FUN==2){ //This doesn't happen.
$("#text").replaceWith( "<h1>Last chance to close the page.</h1>" );
}
$('html, body').animate({ scrollTop: 0 }, 'fast'); //This works- this is the thing that yanks the user's screen back up.
}
};
Edit: This broke it... Thanks @Fabian.
console.log(FUN + " before ++")
FUN++;
console.log(FUN + " after ++")