Reputation: 202
I tried to use document.referrer
. It's working as expected in Chrome, but it's not working as expected in Firefox.
if (document.referrer.indexOf('stringToCheck') > 0) {
//code goes here
}
What happens is,
What would be the issue? Are there any recommendations or alternatives?
Firefox version: 37.0
Upvotes: 5
Views: 4304
Reputation: 25310
Looking at the spec we see that
referrer
of typeDOMString
, readonly
Returns the URI (IETF RFC 2396) of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).
the behavior that you're working with (refreshing the page) isn't explicitly defined.
This means that it's a question of subjective interpretation, and neither browser is doing anything wrong per se, they simply interpret the implication differently:
Both interpretations have use cases when one or the other is better, but neither is wrong or right since the spec is vague.
Upvotes: 3