Xerratus
Happily stressed out, since 1974


 
Thursday, April 13, 2006
<< Movie Quote of the Day
Movie Quote of the Day >>

Throughout any given day, I usually monitor my blogs activities via the DasBlog referrer’s page (Referrers.aspx).  Since I use a tabbed browser (Firefox), I keep the referrer's page open all day in one of my tabs and just go back to it to see the activity up to that point; call it my obsession.  Two things bug me about doing this though.  The first is having to refresh the page manually (not a big deal but an extra step).  The other is when I come back and refresh the page after my session has ended because it prompts me to re-login, and then I have to navigate back to the referrer’s page.

The first idea I had to solve this problem was to add the following code to my admin/homeTemplate.blogtemplate page in the <head> tag.
<meta http-equiv="refresh" content="300">
What this does, for those who don't know, is to automatically refresh the page in 300 seconds (5 minutes) well within my session timeout period.  A big problem arises out of this though; this would go on EVERY admin page including the add entry page.  Simply put, I'd have to add an entry within 5 minutes or else the page would refresh (not postback) and all of my data would be lost.  Not acceptable!

With that said, I had to come up with a way to utilize the <meta> refresh tag (because I like the simplicity of it) but only on the referrers page; enter JavaScript.  By default every page has the document object associated with it, which means that it also has a location object as well.  So all I had to do was check the document.location object for the existing href to see if that string had "referrers.aspx" within it.  If it did, I knew I was on the correct page and could add the <meta> tag.
<script language="javascript" type="text/javascript">
if(document.location.href.indexOf('Referrers.aspx') != -1)
{
// Refresh the page every 300 seconds (5 minutes) document.write('<meta http-equiv=\"refresh\" content=\"300\">');
}
</script>
My solution is simple and can be added quickly by anyone who runs DasBlog as their blogging software.  Simply add the above <script> block to the admin/homeTemplate.blogtemplate within the <head> tag.  Viola, only the referrers page refreshes every 5 minutes.  So activity obsessed people, such as myself, can have easy access to our blog traffic by simply switching to that open tab throughout the day without having to hit refresh and/or re-login back in.