Smart Contracts

Updating Solidity code and Testing a Smart Contract

Books on the Blockchain

Publica Self Publishing

Goodbye Contracting

Hello brave new old world...

Ruby-Selenium Webdriver

In under 10 Minutes

%w or %W? Secrets revealed!

Delimited Input discussed in depth.

Tuesday, 18 November 2014

Auto-refresh a web page

Today I discovered the main website I keep at wasn't live. Shockfest! I say the main site, but it's the main 'static' site, the main site is perhaps the blog over at now. Either way, the website was (is) down and I'm waiting for support to email it's back up.

The email will be appreciated but just trying to load the site is the best way to know it's there. What I don't want to do is keep hitting F5 though. Thankfully HTML has the reload() method available. Wrapped in a little JavaScript we can use this to poll the site and avoid having to refresh it ourselves.

The script is pretty straight forward and useful for other things. You can plug in that auction site, page with a hit counter, flight status or test results dashboard page showing on a large screen in the office.

Paste the below into your favourite text editor and save it as a .html page.

           <script type="text/JavaScript">  
                function pageCheckRefresh(timeoutPeriod) {  
                //  -->  
      <!--- change this to the refresh time you want -->  
      <body onload="JavaScript:pageCheckRefresh(10000);">  
           <!--- This first url is just a control, one we know WILL be there, so we know this checker is working -->  
           <p><iframe height="200" width="750" src=""></iframe></p>  
           <!--- You can have more pages in iframes, just copy the below ( <p> to </p> ) -->  
           <p><iframe height="300" width="750" src=""></iframe></p>  

You'll need to edit two things and add one:

Edit the refresh
It's currently set to 10000, which is 10 seconds.

Edit the target URL
Change to the URL you're interested in.

Add additional URLs
Copy and paste the ...
section and add another URL to check multiple pages.

That's it, straight forward but handy.



Liked this post?

Say thanks by clicking an Ad