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

How to get the correct referrer url in JavaScript? - Stack Overflow

programmeradmin0浏览0评论

If you go to and then e to stackoverflow and then open the console and type:

console.log( document.referrer );

You get

/

instead of

/

How can I get / ?

If you go to http://jsfiddle and then e to stackoverflow and then open the console and type:

console.log( document.referrer );

You get

http://fiddle.jshell/_display/

instead of

http://jsfiddle/

How can I get http://jsfiddle/ ?

Share asked Feb 11, 2013 at 17:41 user967451user967451 1
  • 4 I think that is the correct referrer value - that's the way jsfiddle works. The "result" pane page is in that domain. – Pointy Commented Feb 11, 2013 at 17:42
Add a ment  | 

1 Answer 1

Reset to default 6

You get it because jsfiddle uses frames. Use window.frames.top.document.referrer instead.

发布评论

评论列表(0)

  1. 暂无评论