I'm having a problem about the blinking of the page for my auto-refresh of the page function. Is there a way to make my this blinking of the said page begone? Here's my code:
<script type="text/javascript">
function refreshPage() { location.reload(); }
$(document).ready(function () {
setInterval('refreshPage()', 5000);
});
</script>
Thanks.
I'm having a problem about the blinking of the page for my auto-refresh of the page function. Is there a way to make my this blinking of the said page begone? Here's my code:
<script type="text/javascript">
function refreshPage() { location.reload(); }
$(document).ready(function () {
setInterval('refreshPage()', 5000);
});
</script>
Thanks.
Share Improve this question edited Sep 16, 2013 at 9:51 Sahil Mittal 20.8k12 gold badges68 silver badges91 bronze badges asked Sep 16, 2013 at 9:19 Mr.Bobo HahaMr.Bobo Haha 1411 gold badge2 silver badges16 bronze badges 3-
You can open your page in an
iframe
and then reload that iframe. – Gupta.Swap Commented Sep 16, 2013 at 9:22 - iframe?? how can i achieve that sir... – Mr.Bobo Haha Commented Sep 16, 2013 at 9:25
-
1
Ok, I think i misunderstood your question. If you are trying to add server updates as facebook, then try using some server push technologies like
APE
(ape-project) – Gupta.Swap Commented Sep 16, 2013 at 9:29
1 Answer
Reset to default 2You probably don't want to refresh the entire page. E.g. logo, menu would stay, while a content somewhere will refresh. I would mark this content with e.g. a div
:
<div id="content">
<!-- stuff in here is to be periodically refreshed -->
</div>
Then, I would add a server-side URL to create just that refreshable content. This depends of course on your server-side technology, but it is probably trivial. Say this URL is http://yourserver/path/to/page/content
.
Then with jQuery:
$(document).ready(function () {
setInterval(function() {
$("#content").load("http://yourserver/path/to/page/content");
}, 5000);
});
This is the principle of operation, you may adjust the details. See $.load. This will greatly eliminate the blink.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745627032a4636870.html
评论列表(0条)