在asp及asp.net中隐藏JS文件

来源:互联网 发布:php自动生成昵称 编辑:程序博客网 时间:2024/05/16 19:42

1 在html.asp中用<script src="/js.asp"></script>方式来显示内容

2 在html.asp代码中,设置一个session,在js.asp进行判断,如果是设置的值就显示正常内容,如果不是,就隐藏或显示其它内容,在js.asp的结尾把session值改变

3 在html.asp和js.asp中都加一段代码,使得游览器不缓存页面
html.asp

<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<%
session("seolm") = "hw"
%>
<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" width="480">
    <tr>
      <td id="tmp"><SCRIPT LANGUAGE="JavaScript" src="/js.asp" id="js"></SCRIPT></td>
    </tr>
  </table>
  </center>
</div>
js.asp
<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
if session("seolm") <> "hw" then
response.write "//欢迎查看源文件"
response.end
end if
%>
//高,这你都能看得出来。我没有招了。。哈哈
<%
session("seolm") = ""
%>
在.net中同理