The device is really a projector. You place a special screen/film on the window that the output is seen on.
The device is powered by the vehicle, and is connected to a speed sense line, or an impulse generator (similar to the one used for cruise control). Then the unit is calibrated while on the move to show correct speed.
There are other types that use a gps to provide speed, and others that plug in th the diagnostic port and display all sorts of stuff.