ASP中如何调用js文件中的函数

magicblade 2007-01-24 02:27:57
default.asp:
=======================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<%
response.write "<script language=javascript src=""script/test.js""></script>" + vbcrlf
%>
</HEAD>
<BODY>
<%
response.write "<script>" + vbcrlf
response.write "var o = new obj();" + vbcrlf
response.write "document.write(o.test.name);" + vbcrlf
response.write "</script>" + vbcrlf
%>
</BODY>
</HTML>
===============================


test.js
===============================
function test(recall)
{
this.recall = recall;
this.name = "";
this.value = "";

this.Initialize = function(name, value)
{
this.name = name;
this.value = value;
}
}

function obj()
{
this.name = "this is manager!"
this.test = new test(this);
this.test.Initialize("123456", "This is a test only!");
}
================================



问题:
为什么在asp生成的页面中没有任何信息??

急急急急急,在线等
...全文
873 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chuckcoin 2007-01-24
  • 打赏
  • 举报
回复
document.write改成alert看看是什么东西~
magicblade 2007-01-24
  • 打赏
  • 举报
回复
可是我直接拿到客户端当前目录打开一个html文件也无法在窗口中显示任何东东??
leveretzhang 2007-01-24
  • 打赏
  • 举报
回复
服务器端不能解释客户端的脚本,ASP中的脚本是IIS来解释,JS的脚本是 IE 的解释器来解释,所以当前这种情况不能相互调用,不过你可以用其他方法来解决,比如查询字符串传递值等等
magicblade 2007-01-24
  • 打赏
  • 举报
回复
老大,还是不行呀?
tjgjp 2007-01-24
  • 打赏
  • 举报
回复
function test(recall)
{
this.recall = recall;
this.name = "";
this.value = "";

this.Initialize = function(name, value)
{
name = name;
value = value;
}
}
把函数test.js修改成这样,应该就可以了
redstorm11 2007-01-24
  • 打赏
  • 举报
回复
<head>
<SCRIPT LANGUAGE=javascript src="test.js"></script>
</head>
magicblade 2007-01-24
  • 打赏
  • 举报
回复
没人解忧么?

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧