Nomesh DeSilva Nomesh DeSilva - 20 days ago 6
Javascript Question

Chrome page crash - reload page automatically

I'm running an Ajax based single web page application which runs in every 1 second interval to update a DIV contents. after running 4-5 hours, Google chrome page crash message appears with the reload button.

Is there anyway to capture this event and to reload the page again automatically?
URL is always the same. please help !

Answer

This Error happens because Ajax has some kind of limit on requests you can make without a reload.

If you want this to work fluently, use an iframe in the following way.

index.htm

<iframe src="inframe.htm"></iframe>
<script>
// ..
</script>

inframe.htm

<!-- Refresh every 3 Seconds -->
<meta http-equiv="refresh" content="3">
<p>iFrame Content</p>

This is probably not the way you want it to work, but the point is that the iframe will reload itself after 1 second.

Pros:

  • You don't have to worry about Ajax' limit
  • It doesn't need jQuery and you can still edit the request values using iframe.src = "...";

Cons:

  • Some users block iframes
  • The iframe is empty while it (re)loads
Comments