Bojangles
Bojangles

Reputation: 467

Refresh the browser client side without hitting the server

I would like to be to refresh the browser window without hitting the server, I’m guessing javascript is a good way to go? I have the following code but I’m unsure what it’s doing exactly!

<body onload="JavaScript:AutoRefresh(5000);">

<script type="text/JavaScript">
<!--
        function AutoRefresh(t) {
            setTimeout("location.reload(true);", t);
        }
//   -->
</script>

If that’s just refreshing the browser client side then great but if not how should I go about it?

Upvotes: 1

Views: 5444

Answers (2)

gopi1410
gopi1410

Reputation: 6625

Both <meta http-equiv="refresh" content="5" /> (refreshes every 5 seconds) and window.location.reload refresh the browser client side but fetch data from the server.

Its not possible to refresh or reload a page within getting data from server. If you want to do client side refresh like clearing a HTML5 canvas, you have to adopt specific means like setting width works for clearing a canvas, & other methods for other objects as per your needs.

Upvotes: 2

Quentin
Quentin

Reputation: 943560

I would like to be to refresh the browser window without hitting the server

You can't, by definition. Refreshing the page means making a request for a fresh version from the server.

Upvotes: 0

Related Questions