问题
In a normal browser javascript environment, you always have the global window
object to fall back on but is there a default accessible global object for the Microsoft JScript Runtime or at least a way to check for one?
回答1:
According to MSDN, there is a Global
object, however a quick test reveals that it is not directly accessible:
WScript.Echo(Global.escape('hello world')); // Error: 'Global' is undefined
What you can do, however, is take advantage of the fact that this
in a global context refers to the global object and save the reference to a variable:
var __global__ = this;
WScript.Echo(__global__.escape('hello world')); // happy times
来源:https://stackoverflow.com/questions/14450424/equivalent-to-window-in-jscript-runtime