I know I can get the host name of the current page, by simply doing:
var myhostname = location.hostname;
var referrer = document.referrer;
By parsing it.
referrer.split( '/' ); will get you close. Or take a look at this
If referrer is coming from a browser, it will be sane -- but just in case you want more robust parsing.