服务器端JavaScript - 传统的ASP [英] server-side javascript - classic asp

查看:122
本文介绍了服务器端JavaScript - 传统的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 append this. to global objects like Response (as Shadow Wizard suspected):

this.Response.write("foo!");

Works fine. But you cannot reflect on the this object itself. Trying for(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屋!

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