admin管理员组文章数量:1025539
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.
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.
版权声明:本文标题:javascript - is auto-refresh is possible in jquery without making the page blink?? like in facebook - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745627030a2159925.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论