"Numerous insects, such as common houseflies, as well as certain amphibians and reptiles (tree frogs and geckos, for example), are able to walk on and cling to seemingly smooth surfaces--including glass doors and windows.
"This trick is accomplished not by suction cups or adhesives but rather by a large number of tiny bristles or hairs on the bottom surface of the animals' feet. Scientists have produced scanning electron microscope images of these bristles. Surfaces that appear perfectly smooth to us actually have many microscopic bump and fissures, which serve as footholds for the tiny hairs."
Richard D. Fell, associate professor in the department of entomology at Virginia Polytechnic and State University, adds some other details:
"The segments, or tarsi, at the end of insect legs possess clawlike structures that help the insect hold on to different types of surfaces. These tarsal claws are used to grip the tiny irregularities on rough surfaces. But in some cases, insects do make use of a kind of adhesion. If the surface is smooth, the insect can hold on using the adhesive action of hairs located on sticky pads (known as the arolia or pulvilli) on the tarsi.
"Some insects, such as grasshoppers, have pads on each of their tarsal segments, and some insects may have special adhesive pads on other segments of the leg. The pads typically contain numerous hairs that secrete an oily substance that causes the tips of the hairs to adhere to the surface. This substance provides the traction and stickiness that allows insects to hold on to smooth surfaces, such as glass.