用Javascript隱藏超級連結的真真實位址

來源:互聯網
上載者:User
用Javascript可以隱藏超級連結的真真實位址:
在顯示下載連結的頁sample.aspx的前台合適地方加入以下代碼如下:

<a 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);
            }

當滑鼠打向開啟視窗時,出現的連結資訊是#,而不是下載檔案的連結地址,從而達到隱藏真實的超級連結地址的效果!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.