About preventing file download hotlinking use JS to prevent file address hotlinking (i)

Source: Internet
Author: User
Tags servervariables
js| Download

/*bluedestiny (Blue fate) * *

Download hotlinking questions, the beholder, the benevolent; here is only a purely discussion technique.
If it is the page anti-theft chain, the usual method is to use ServerVariables ("SERVER_NAME") combined with ServerVariables ("Http_referer") to prevent. As follows:
DIM Servurl, Fromurl
Servurl = Request.ServerVariables ("SERVER_NAME")
Fromurl = Request.ServerVariables ("Http_referer")
If (Mid (Fromurl,8,len (Servurl))) <> Servurl Then
Response.Write (' <script>alert (' please login from the right page! ') </script> ")
Response.End
Else
......
End If
There is also a combination of session to prevent page hotlinking and file hotlinking.
Then there is the server side to set.
The above method, I will write out in the future article, below let us see how to use JavaScript (pure static file) How to prevent file hotlinking? The following source code only to play a role, I hope that we have more comments.
---------------------------------------------------------------------
**********************************************

First, for example, we have a music audio-visual page. The source code is as follows:
First build a folder is: MusicMP3, under this folder put a Mp3,mp3 renamed to 921239.mp3

---------------------------------------------------------------------
***********************************
music.htm
-----------------
<title>music</title
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312"
<script Language= "JavaScript"
Function play (URL) {
  play_win=window.open (' play.htm?url= ' +url, ' Bluedestiny ', ' Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, copyhistory=no,width=470,height=290,top=210,left=158 ');
}
</script>
<body>
<p> <a href= "#" >MUSIC1</A></P>
</body
How can there be a long string of characters? Note The format of this long string of parameters, which is useful later.

---------------------------------------------------------------------------------
**************************************************
About preventing file download hotlinking use JS to prevent file address hotlinking (ii)
Http://blog.csdn.net/bluedestiny/archive/2004/09/23/114164.aspx
---------------------------------------------------------------------------



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.