How do you get the Url Referer via a javascript include?

前端 未结 2 434
谎友^
谎友^ 2020-12-28 14:06

If I search for something on google and click on a result (mytestsite.com), the referer to that site will be URL of the google search.

Now on that site, there is a J

2条回答
  •  忘掉有多难
    2020-12-28 14:53

    I'm a little unclear on what you are trying to do, but you can grab the referrer with JavaScript using:

    document.referrer
    

    ...and pass it along to the server in your request for the JS file. Several ways to do this...here's one:

    
    

提交回复
热议问题