Created
July 19, 2013 04:06
-
-
Save nansenat16/6035091 to your computer and use it in GitHub Desktop.
示範更換分頁停止倒數
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<script type="text/javascript"> | |
var count=0; | |
$(window).blur(function(){ | |
console.log('out'); | |
$('#msg').data('where','out'); | |
}); | |
$(window).focus(function(){ | |
console.log('in'); | |
$('#msg').data('where','in'); | |
}); | |
setInterval(function(){ | |
if($('#msg').data('where')=='in'){ | |
$('#msg').text(count); | |
count=count+1; | |
} | |
},1000); | |
// you can stop blur on develop console | |
// $(window).off('blur') | |
</script> | |
</head> | |
<body> | |
<div id="msg" data-where="in" style="width:100px;height:100px;background-color:green;color:red;font-size:40pt;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment