服务器端JavaScript - 传统的ASP [英] server-side javascript - classic asp
问题描述
在客户端JavaScript的本操作符是window对象。
什么是本运营商在传统的ASP服务器端JavaScript?
在以下code,什么是本,在传统的ASP服务器端运行时参考?
测试();功能测试()
{
的Response.Write(typeof运算(本));
}
的这个
对象似乎在服务器端ASP页的全球范围内接受特别治疗。在我的测试中,可以追加这个
像响应全局对象
(暗影精灵怀疑):
this.Response.write(富!);
正常工作。但你不能在反映这种
对象本身。试图的(在此VAR键)
抛出异常:
未处理的异常('对象不支持此操作)发生的w3wp.exe [5868]
块引用>您得到相同的异常只是用于测试的存在
这个
:如果(本){...}
因此,它是不是在所有正常的JavaScript对象,以及(如暗影精灵说的)是在全球范围内pretty没用的。
In client-side javascript the "this" operator is the window object. What is the "this" operator in classic asp server-side javascript?
In the following code, what is "this" referencing when run in classic ASP server-side ?
test(); function test() { Response.Write(typeof(this)); }
解决方案The
this
object seems to receive special treatment in the global scope of a server-side asp page. In my tests, you can appendthis.
to global objects likeResponse
(as Shadow Wizard suspected):this.Response.write("foo!");
Works fine. But you cannot reflect on the
this
object itself. Tryingfor(var key in this)
threw an exception:An unhandled exception ('Object doesn't support this action') occurred in w3wp.exe [5868].
You get the same exception just for testing the existence of
this
:if (this) { ... }
So it is not a normal javascript object at all, and (as Shadow Wizard says) is pretty useless in the global scope.
这篇关于服务器端JavaScript - 传统的ASP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!