Web browsers provide a host environment in which to view a web page downloaded from a remote server or from a local file system. Scripts running in that browser use an object model representation of the browser and the presently viewed document. These are called the Browser Object Model and the Document Object Model respectively. There are objects to represent windows, dialog boxes, alerts, text areas, anchors, frames and all the functionality that the browser provides through its graphical user interface.
The host environment provides a means of connecting events to scripts and those scripts are then triggered when the user interacts with the document or browser. Because the entire complex provides a framework for execution and that execution is event driven, there is no main() function as you would have with the C language for example.
A complete web-based application can be built with code distributed between the server and client environments.