thescor420 thescor420 - 22 days ago 5x
Javascript Question

External domain JavaScript referrer? how it works?

so I have a question and I can't find an answer.

So I have a domain which has a button that redirects to has an JS code to tell the referrer and if te referrer is dario1 it will run a JS. And that works perfectly.

var ref1= document.referrer;
var search = "dario1";
if (ref1.indexOf(search) > -1)

My question is:
If has this code(in head tags) in an external JS on another domain like i dont own).Can the site tell my referrer? Or it will show

type="text/javascript" src=""

I dont know how to test this(don't own more domains, also jsfiddle is kinda embeed so I don't know if it's good.), and also I want to be sure.


javascript runs on the local machine only. So anything you put in the src= attribute is basically telling your client to request the code from a particular location and run it locally. It does not matter where the code comes from, it will always be run the same!

The only way to access where the code came from (see what is inside the src attribute), is to look at the dom itself.

So to recap, the code you have pasted in your question will always run exactly the same, no matter where is was requested from.