Reputation: 71
I am trying to write a code to make a page reload when a new Post is set. So I figured that I could use the variable as an image, since everytime a new post is set,the image of new post appears.
I started using the meta http refresh code.
I could use jQuery or javascript (i know they are same, just written differently)
I just know I'd like to have the page auto refresh with the condition of if image is appeared. or (new post)
Please dont negative vote this, I know Im jabbering on, but i guess i can't find the words I wanna say.
<script type=”text/javascript”>
function pageRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
</script>
and maybe i could use onSubmit, onLoad, onReady, or something that would work in this question. UGh lost for words
Upvotes: 0
Views: 158
Reputation: 6408
First of all: Javascript and jQuery are not at all the same! Javascript is a programming language and jQuery is a framework, written in and for javascript. Don't get confused here.
For your actual problem, you can refresh the page periodically, just like you did with the metatag. If you want to update the page only when the content has changed, then you have to set up some service, that can give you a clue that the content has changed. But for this, you would have to make this service on the server side to be consumed by javascript on the client side.
You should read about AJAX for a better understanding of what you really want.
Upvotes: 0
Reputation: 148120
Try this,
function pageRefresh(timeoutPeriod) {
setTimeout(function(){location.reload(true)}, timeoutPeriod);
}
Upvotes: 2