最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

url - Javascript document.referrer with full querystring - Stack Overflow

programmeradmin5浏览0评论

I am trying to get the full referring url to a page via javascript.

So far the closet I have e is

var lastUrl = document.referrer;

This does not include the query attached to the url.

var lastUrl = document.URL;

returns the current URL with the querystring intact.

Is there anyway of easily obtaining the referring url along with the referring query.

I am trying to get the full referring url to a page via javascript.

So far the closet I have e is

var lastUrl = document.referrer;

This does not include the query attached to the url.

var lastUrl = document.URL;

returns the current URL with the querystring intact.

Is there anyway of easily obtaining the referring url along with the referring query.

Share Improve this question asked May 15, 2014 at 15:33 SideshowSideshow 1,3516 gold badges28 silver badges50 bronze badges 4
  • Could you share us an example? – naota Commented May 15, 2014 at 15:40
  • document.referrer will bring back for example http://mydomain./paths/file.php, this being the previous referring page where as I require http://mydomain./paths/file.php?inherit=true&id=123. Using document.URL will bring the full path but of the currently viewed page – Sideshow Commented May 15, 2014 at 15:47
  • This page might help you. stackoverflow./questions/2680328/query-string-in-javascript – naota Commented May 15, 2014 at 15:54
  • Thanks, but I looked at these - may be able to munge the first answer to something useful though. – Sideshow Commented May 15, 2014 at 16:07
Add a ment  | 

1 Answer 1

Reset to default 9

You cant. You can navigate user to previous page with

window.history.back();

but you will not know what url it was. You can get only this:

document.referrer

i know, it's not full query with url, but it's referrer.

P.s. Would you like, that any page would be able to check where you've been before? Some pages use authentication via url, so anyone would be able to grab those links from your browser's history.

发布评论

评论列表(0)

  1. 暂无评论