Described is a mechanism for executing a hosted application in either a
browser-execution environment or as a standalone application. The
invention provides a mechanism that enables hosting code in either of
plural hosting environments. Briefly stated, code is created that
executes in a common execution environment. That execution environment
can be either owned by a browser or not. When the code is launched, a
host sniffer component determines from an indicator within the code which
hosting environment is appropriate. Based on that indicator, the code is
launched in the appropriate hosting environment. The appropriate hosting
environment may be either browser hosted or standalone.