等效于JScript Runtime中的窗口 [英] Equivalent to window in JScript Runtime

查看:82
本文介绍了等效于JScript Runtime中的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在普通的浏览器javascript环境中,总是有全局window对象可供使用,但是Microsoft JScript Runtime是否有默认的可访问全局对象,或者至少是一种检查对象的方法?

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?

推荐答案

根据

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

但是,您可以利用以下事实:全局环境中的this引用全局对象,并将引用保存到变量中:

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

这篇关于等效于JScript Runtime中的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆