用Javascript隐藏超级链接的真实地址

用Javascript可以隐藏超级链接的真实地址:
在显示下载链接的页sample.aspx的前台合适地方加入以下代码如下:
< href ="#"  onclick ="javascript:window.open('DownLoad.aspx?ID=11','newwin','width=350,height=510,scrollbars=0,toolbar=0,resizable=0')" > 打开窗口 </ a >  

通过DownLoad.aspx文件读取需下载的文件信息,在后台加入代码:
 
try
            
{
                
string str = "select FileContent,FileType, FileName from fileinfo where id = " + base.Request.QueryString["id"];
                SqlDataReader Dr 
= pubValue.DataRead(str);

                
string strfilePath = "file/" + base.User.Identity.Name;
                
string path = "";

                
if (Dr.Read())
                
{
                    
string s = Dr["FileName"].ToString();
                    path 
= base.Server.MapPath(strfilePath + "/" + s);

                    
if (File.Exists(path))
                    
{
                        File.Delete(path);
                    }


                    FileStream stream 
= new FileStream(path, FileMode.Create);
                    stream.Write((
byte[])Dr["FileContent"], 0, ((byte[])Dr["FileContent"]).Length);
                    StreamWriter writer 
= new StreamWriter(stream);
                    writer.WriteLine(
"");
                    writer.Flush();
                    writer.Close();
                    stream.Close();
                    
base.Response.Write("<script>location.href='" + strfilePath + "/" + base.Server.UrlEncode(s).Replace("+""%20"+ "';</script>");
                }

            }

            
catch  (Exception exception)
            
{
                
base.Response.Write(exception.Message);
            }

当鼠标打向打开窗口时,出现的链接信息是#,而不是下载文件的链接地址,从而达到隐藏真实的超级链接地址的效果!

转载于:https://www.cnblogs.com/wlq2000/archive/2007/11/16/961738.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值