Getting kids to focus while on the computer is going to take a little bit of effort before even getting on the computers. One of the first things you are going to have to take into consideration is the age of the children in which you are trying to instruct. Your strategy for elementary students is going to be totally different for high school students. When formulating a strategy to keep kids focused while on the computer taking a few minutes to analyze a few key factors that are going to help you in the long run. Ask yourself: how long you can keep their attention in regular class activities, what strategies seem to work when away from the computer, and what motivations you can use to help them want to stay focused.
Before beginning to work on the computers you should take a few minutes to explain what the consequences will be if they get sidetracked by games or more interesting sites on the internet. Telling the students this beforehand will give them the opportunity to use this information to make the right decision.
Also giving them amble breaks, this depends on their age and length of time they can focus, and an incentive that if they get all their work done they can have free time at the end of the class period.