Code runs perfectly in HTML file, but when used in PHP file the javascript seems to be the only thing that fails. Does anyone know a reason why?
This code is supposed to make a appear after a certain amount of time with out mouse movement. if the user moves their mouse, the will .fadeOut();. However if the user doesn't move the mouse, then they are redirected to another url after a few more seconds.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$('#showdiv').fadeOut();
var timedelay = 1;
function delayCheck()
{
if(timedelay > 5)
{
$('#showdiv').fadeIn();
if(timedelay == 12)
{
window.location = "https://www.google.com";
}
timedelay = timedelay+1;
}
$(document).mousemove(function() {
$('#showdiv').fadeOut();
timedelay = 1;
clearInterval(_delay);
_delay = setInterval(delayCheck, 900);
});
// page loads starts delay timer
_delay = setInterval(delayCheck, 900)
</script>
<style type="text/css">
#showdiv{
width: 450px;
border-radius: 10px;
padding: 50px;
border: 2px double gray;
position: absolute;
top: 40%;
left: 40%;
}
</style>
</head>
<body>
<div id="showdiv">
<h2>
You will be redirected in a few second unless you move your mouse.
</h2>
</div>
</body>
</html>