2
  1. What I wanted to do is set different referer for every Link:

The Links

2.The explanation below is my attempt:

Code 1:

<a class="mymovie"
    mytitle="<s:property value="movieLink"/>"
    title="<s:property value="movieDownloadPath"/>" 
    href="javascript:void(0)">
      <s:property value="movieName"/>
</a>

Code 2:

$(".mymovie").click(function(){
    $.ajax({
      type:"get",
      url:$(this).attr("title"),
      beforeSend: function(request) {
                    request.setRequestHeader("Referer", $(this).attr("mytitle"));
                },
   });
   alert($(this).attr("title"))
});
  1. The effect

chorm,jquery-2.1.4.min.js:4 Refused to set unsafe header "Referer",jquery-2.1.4.min.js:4 XMLHttpRequest cannot load “This is a FTP link to download movie(like:ftp:/.....rmvb)” Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

the effect in chorm

In Firefox,when I click one link, there is no effect. Any idea?

Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
Rail
  • 81
  • 2
  • 3

1 Answers1

0

Generally, changing the referer header is not allowed. There seems to be a workaround, though:

delete window.document.referrer;
window.document.__defineGetter__('referrer', function () {
    return "yoururl.com";
});
Community
  • 1
  • 1
UltraInstinct
  • 43,308
  • 12
  • 81
  • 104