Gravity and the syphon action is the main principle behind how an overflow works.
Ill break this down hopefully not to simple.
A hang on overflow has three main components. These components include a box that goes inside the tank, a box that goes outside the tank and a water channel to take the water from the inside box to the outside box by lifting it up and over the side of your tank.
The inside portion of the overflow often has little 'fingers' cut into it to strain the water. This keeps large particles from going into the box.
The outside box has two sections. One section has a hole in it to attach a drain line and the other has a solid bottom. The sections are divided by a pit of acrylic or plastic that goes up anywhere between 1/3ed to 1/2 the height of the outside box.
The channel that moves the water from the inside to outside box goes has one end that goes into the inside box and has another end that goes into the outside box and specificly in the side that does NOT have the drain line.
Different overflows use different methods to do the following...
With water in both the inside box and in the solid bottom side of the outside box you remove the air from the connecting channel. This is in effect priming the water channel. This can be done by inserting an airline and pulling the air out via your mouth or by having the airline connected to a powerhead and using the ventri action of the PH
to pull the air out.
Once you have all the air out of the channel and you have both ends submerged under water the channel will hold water. When the water level in the box that is inside the tank rises above the water level of the outside box the action of a water syphon will start to pull water out if the inside box and into the outside box. The small chamber will fill with water and then dump into the other chamber where the drain line is. Water then drains down to the sump or wet/dry.
A pump then returns the water to the tank thus putting more water into the tank to then go into the inside box of the overflow and thus the whole process keeps going. Keeping the water channel free of excess air is critical in keeping the syphon process going. If this is free of air then powering off the pump will stop the overflow's operation but at th esame time not cause the water channel to lose its prime.
There are two main types of hangon overflows. You have the "U" tube type and then the "C shell" type. These two types basicly describe the shape of the water channel. The U tube type uses tubes that are in the shape of a U that take water up and over the side of the tank. This can also be refered to as a "J" tube. The "C shell" type is different in that the water channel runs the entire lenght of the overflow and is often thinner resulting in a smaller profile overflow.
One of the best ways to get how this operates in your mind is to see one in action.