user967451
user967451

Reputation:

How to get the correct referrer url in JavaScript?

If you go to http://jsfiddle.net and then come to stackoverflow and then open the console and type:

console.log( document.referrer );

You get

http://fiddle.jshell.net/_display/

instead of

http://jsfiddle.net/

How can I get http://jsfiddle.net/ ?

Upvotes: 0

Views: 10830

Answers (1)

marekful
marekful

Reputation: 15351

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

Upvotes: 6

Related Questions