Search code examples
javascriptlocationreferrerpathname

Javascript pathname referrer


How can do the same function in javascript that is document.location.pathname - except with the referrer? so something like document.referrer.pathname?

Thanks.


Solution

  • No, you can only extract needed part manually:

    document.referrer.replace(/^[^:]+:\/\/[^/]+/, '').replace(/#.*/, '')