If you use Google Analytics, you place javascript on your web page and it does, indeed, log the referring URL, along with lots of other information about your web site's visitors. So javascript certainly can be used to track that information.