Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Wednesday, September 26, 2012

Auto refresh page with Javascript & Meta tag

1. Using meta tag, for example to auto refresh to your url every 1 second.
<meta http-equiv="refresh" content="1;url='http://your_url' " />

2. Using Javascript, for example to auto refresh to your url every 1 second:
<script>
  function auto_refresh() {
    window.location = 'http://your_url';
  }
  setTimeout(auto_refresh, 1000);
</script>


3. Using Javascript + jQuery to auto refresh when having no activity in some minutes (e.g. 1 minute)
<script>
     var time = new Date().getTime();
     $(document.body).bind("mousemove keypress", function(e) {
         time = new Date().getTime();
     });

     function auto_refresh() {
         if(new Date().getTime() - time >= 60000)
             window.location.reload(true);
         else
             setTimeout(auto_refresh, 10000);
     }

     setTimeout(auto_refresh, 10000);
</script>


Friday, February 17, 2012

Why does Google create Dart?

I think Google want to use Dart engine (VM) to speed up web apps instead of the current Javascript engine (VM).
However the developers will decide to use Dart or not. It's depended on if Dart engine is supported by the other browsers and how to solve problems of Dart which is a new language without large community.
Subscribe to RSS Feed Follow me on Twitter!