Pau*_*how 2 vbscript asp-classic
我正在尝试使用经典 ASP 将当前目录的绝对路径打印到浏览器屏幕。(相当于 PHP 的 echo 命令)。
我在下面代码的最后一行收到此错误:“Microsoft VBScript 运行时错误 '800a01a8' 所需对象:'文档'/Research/ro.asp,第 17 行”
我尝试了几种不同的方法来打印到屏幕(如 WScript.StdOut.Write),它们也返回相同的错误。
我怀疑我的错误与它是一个对象的事实有关,并且对象需要不同的打印到屏幕的方法。
任何人对此有何想法?
示例文件.asp=
<%
Dim szCurrentRoot: szCurrentRoot= ""
'Create the File System Ojbect
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Get the Absolute Path of the current directory
szCurrentRoot = objFSO.GetParentFolderName(Server.MapPath(Request.ServerVariables("URL")))
'Print to the screen. The following line is line 17 which causes the error
Document.Write(szCurrentRoot)
%>
Run Code Online (Sandbox Code Playgroud)
经过更多研究,我找到了我的问题的答案:
Response.Write(szCurrentRoot)
这种写入浏览器屏幕的方式是成功的。
<%
Dim szCurrentRoot: szCurrentRoot= ""
'Create the File System Ojbect
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Get the Absolute Path of the current directory
szCurrentRoot = objFSO.GetParentFolderName(Server.MapPath(Request.ServerVariables("URL")))
'Print to the screen.
Response.Write szCurrentRoot
%>
Run Code Online (Sandbox Code Playgroud)
Response.Write是将文本数据发送回客户端的方式。使用<% %>是此方法的快捷方式。
| 归档时间: |
|
| 查看次数: |
7199 次 |
| 最近记录: |