JScript 中 eval 实现 VBScript ExecuteGlobal 功能, 函数 fExecuteGlobal by shawl.qiu
2007-09-09 11:41
741 查看
JScript 中 eval 实现 VBScript ExecuteGlobal 功能, 函数 fExecuteGlobal by shawl.qiu
说明:顾名思义, ExecuteGlobal 就是把局部变量弄成全局变量...
虽然实现函数只是短短几行...
不过这几行中包含的原理实在是太多了, 俺不想费劲解释... 请自行消化.
shawl.qiu
2007-09-09
http://blog.csdn.net/btbtd
内容:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>shawl.qiu template</title>
</head>
<body>
<%
fTest("j");
Response.Write("i: "+i+"<br/>");
Response.Write(typeof(i)+"<hr/>");
Response.Write("f: <xmp>"+f+"</xmp><br/>");
Response.Write("Global: "+typeof(f)+"<br/>");
Response.Write("j: <xmp>"+j+"</xmp><br/>");
Response.Write("Global: "+typeof(j)+"<br/>");
function fTest(DynArg)
{
var i=0;
fExecuteGlobal("f", f);
fExecuteGlobal("i", i);
if(DynArg) fExecuteGlobal(DynArg, eval(DynArg));
function j()
{
Response.Write("j saying hi.<br/>");
}
function f()
{
Response.Write("f saying hi.<br/>");
}
}
function fExecuteGlobal(sVar, Var)
{ // shawl.qiu code, void return
if(!sVar) throw new Error("var name must be not empty!");
eval(sVar+"=Var");
} // function fExecuteGlobal(sVar, Var)
%>
</body>
</html>
相关文章推荐
- C#动态执行类库中的函数:利用反射实现(js)Eval,asp(Execute)功能
- 服务端 VBScript 与 JScript 几个相同特性的写法 By shawl.qiu
- ASP VBScript 函数 之返回多个值 By shawl.qiu
- VBScript之Eval函数与Execute语句(Array.ForEach的实现)
- asp jscript 调用 asp vbscript class/类, by shawl.qiu
- 服务端 VBScript 与 JScript 几个相同特性的写法 By shawl.qiu
- asp jscript, vbscript 的 动态交互 与 动态加载 By shawl.qiu
- ASP VBScript 动态包含文件, FSO 实现 By Shawl.qiu
- C#利用反射实现(js)Eval,asp(Execute)功能 动态执行类库中的函数
- 重写与扩展 JScript/Javascript String 对象的 HTML 函数 By shawl.qiu
- 服务端 JScript 记录集分页函数/对象 By shawl.qiu
- 在.net 1.x 中, 实现多语言功能, by shawl.qiu
- 服务端 VBScript 与 JScript 几个相同特性的写法 By shawl.qiu
- VBScript之Eval函数与Execute语句(Array.ForEach的实现)
- VBScript之Eval函数与Execute语句(Array.ForEach的实现)
- ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
- Javascript 单数组实现列表框两级联动三级联动 By shawl.qiu
- VBScript 使用 xmldom 检测/创建/读取/更改 XML 文件数据 实例 By shawl.qiu
- javascript 简单高效判断数据类型 系列函数 By shawl.qiu
- 服务端 jscript 生成随机数图片验证码 by shawl.qiu