But that would only mean anything if your visitors leave the page open
in their browsers all day. What you might want to do is simply add a
cache-blocking element to your URL, like this:
<script type="text/javascript">
//check if the page already has a querystring
var d = new Date();
if(!!window.location.search){
var u = window.location.href;
if((parseInt(u.split('?')[1]) + (1000 * 21600)) < d.getTime()){
window.location.href = u.split('?')[0] + '?' + d.getTime();
}
}else{
window.location.href = window.location.href + '?' + d.getTime();
}
</script>
What this does is check to see if the page URL already has a
querystring that looks like this:
yourpage.html?1268753907163
…(where that number is the number of milliseconds since January 1,
1970). If it does, then it further checks if that number is inside
your 6 hour window. If it is, then the script ends at that point.
(There’s very little point setting a timeout to 6 hours in JavaScript
since the script cancels the moment the visitor blurs away from the
page.)
If there isn’t such a querystring, then the page reloads and adds the
querystring.
If the visitor bookmarks the page, or just goes back in her history,
then the querystring will be out of date and the page will refresh.
And Google will crawl and cache the page without any querystring,
since it doesn’t execute any JavaScript on the pages it visits (so the
“first run” behavior will never occur). So any human entering the site
from a Google link will magically refresh to the latest version the
moment the page opens.
If your page already uses a querystring for something else (a form
using the GET protocol?), then you should avoid this technique or
modify it to work along with your existing querystring scheme.
Walter
On Mar 16, 2010, at 10:31 AM, Adrian Williams wrote:
Justin,
Change this…
setTimeout(“refresh_location()”, 100060); // 1000 ms * 60 = 60
seconds
To this…
setTimeout(“refresh_location()”, 10003600); // = 1 hour
Or this…
setTimeout(“refresh_location()”, 1000*21600); // = 6 hours
Adrian
On 16 Mar 2010, at 14:18, Justin Easthall wrote:
Thanks people - to get it to refresh twice a day i would need
to… sorry not a coder
J
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options