执行出错,该怎么改?

哈哈 2004-12-22 09:40:28
<!--#include file="guanggao-<%=request("bianhao")%>.asp"-->
执行出错,该怎么改?
实现在不同的页面中嵌入不同的广告页
...全文
94 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
patchclass 2004-12-22
  • 打赏
  • 举报
回复
<!--#include 是预编译的,不可以带参数
你用server.execute试试吧
whb147 2004-12-22
  • 打赏
  • 举报
回复
include里面不能使用<% %>
TSD 2004-12-22
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>EG</title>
</head>

<body>
<iframe src="<%=request("bianhao")%>" widhth=100 height="100"></iframe>
</body>
</html>




---------------


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>EG</title>
</head>

<body>
<script language="javascript" src="<%=request("bianhao")%>.js"></script>
</body>
</html>
nattyfish 2004-12-22
  • 打赏
  • 举报
回复
受<! #include file="filename.asp" --> 宏限制
必须存在该文件并且会预先编译(不管前面是否加以条件)

经常有这样的要求,根据不同的需求要求include不同的文件
如各个人的不同设置,所以要求能动态include文件。

代码如下:

Function include(filename)
Dim re,content,fso,f,aspStart,aspEnd

set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing

set re=new RegExp
re.pattern="^\s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
do while aspStart>aspEnd+1
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%\>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
set re=nothing
End Function

使用范例:

include("youinc.asp")


TSD 2004-12-22
  • 打赏
  • 举报
回复
你这种写法是错误的!!!ASP不能这样子引用,你只能通过用IFRAME嵌入不同的页面,或JS
micher_yan 2004-12-22
  • 打赏
  • 举报
回复
没有错误啊,你有传入参数bianhao吗?
nattyfish 2004-12-22
  • 打赏
  • 举报
回复
include里面不能使用<% %>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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