Detecting an Internet Connection With Javascript

The other day I was developing small client-server application where I needed to check using Javascript on the client’s side whether active Internet connection exists, before submitting request to the server.

Javascript does not allow you to do ping, and even so many websites protect against ping requests (ICMP echo), so I had to come up with some alternatives.

One of the nice solutions that I have found is to create an Image object and to specify as image source, URL to an image located on a remote server. Then to test, if the newly created Image object has height or width greater than zero.

If it is greater, what it means is that there is active Internet connection, since it was possible to create Image object using image or icon located on a remote server.

The downside here is that path to the image or image filename may change in the future on the target remote server, and as a result of that your Javascript function will stop working.

While thinking what image should I link to, I decided to use Google’s favicon. I tend to think that the favicon is not something that is going to change very often. I also considered to use Goggle logo, but favicon is much smaller in size.
(Another thing worth remembering is to allow some time to retrieve the remote image, which is another reason why I went for the favicon).

The solution is:

function testConnection() {
   var googleFavIcon = new Image();
   googleFavIcon.src =

   if(googleFavIcon.height>0)  {
       //do something
    else {
      //warn user

Just keep in mind, that the remote image is cached once you got it. If you decide to test connection again, you have to make sure that you are not using the cached image, but trying to retrieve it again from the remote server. To prevent caching, you can add some random parameter to the URL:[random-value]

Blogging Software Pebble is Almost Six Years Old!

Simon Brown, the creator of Pebble blogging tool has retired. He stepped back due to personal reasons after 5 years of leading the Pebble project. Pebble is an open source blogging tool, written in Java. The following post, is the first post when Simon announced release of Pebble.

I have been using Pebble for the past year, and I have to say that I am absolutely pleased and delighted. As a Java programmer I find this blogging application to be simply amazing. It is highly configurable, and if you want to extend its functionality – you can! It is very easy to create your plug-in and add it to Pebble system. Off course you need to understand a bit of programming in Java to be able to do so.

Pebble is not as full featured tool as WordPress for example, but it has strong support of loyal followers that contribute to the project with new features and enhancements. As time passes by, Pebble’s community only getting bigger and stronger. A t this moment, Pebble has all the necessary features that powerful blogging tool must have. You can make a really powerful website with the help of Pebble.

I really did not mean to let this post to sound like some promo, its just Pebble is so great that I am just happy to spread the word :)

Thank you Simon, and good luck in your future endeavors.

Australian Citizenship – The Ceremony

I am officially Australian now :)

My long time dream to become part of this country has finally came true. It was made official on 11th of December 2008 after approximately two months I have lodged the application.

The citizenship ceremony was held in Melbourne CBD, near the office of Department of Immigration, in the place called Royal Australasian College of Surgeons. I think the reason for that was the fact that the building is quite beautiful and has several halls suitable for this type of formal ceremonies:

Royal Australasian College of Surgeons

Royal Australasian College of Surgeons

The were not many people attending ceremony together with me. I would say around 15 people with additional 30 friends and family. When I arrived there, lady at the entrance found my name on the attendees list, and gave me my citizenship certificate and Australian citizenship pledge card.

I was a bit surprised that the ceremony was not exactly what I have expected:

I thought a representative of Aboriginal community will be present at the ceremony, and will be giving us our certificates one by one as we go on stage. Also, I thought that us, new citizens of Australia will be given a little tree to plant (I got this impression from several people that I know that already got Australian citizenship).

Well, a representative of Aboriginal community was not there, and we were not given a little tree to plant. Instead, some lady with sleepy face from Department of Immigration was present to conduct the ceremony.

Honestly speaking, not having an Aboriginal person there and a little tree were just some minor details. What was really important, the fact that I was becoming Australian and at the end of the day I did not really care whether my new Government gave me a tree or not :)

The conducting ceremony lady got on a small stage and began by explaining us our duties and privileges as Australian citizens. Following that, she invited us to say the Australian citizenship pledge. We all stood up, and started reading from our cards.

After that, the lady has congratulated us for becoming Australian citizens and we were free to take pictures (if we wanted to). The little stage had Australian flag on it, and a picture of the Queen. We were also offered tea and cookies :).

I attended the ceremony with my girlfriend and my uncle, and after taking few pictures we went home.

Australian Citizenship Certificate

Australian Citizenship Certificate

The above is a thumbnail of my citizenship certificate, just click on it if you want to see the larger picture. The link will open in the new window.