is it possible to in javascript like in php header location, if the visitor comes from index html alert something? and how ? thank you
-
3Can you clarify that question a bit? At the moment people will be guessing at what you're asking.T.J. Crowder– T.J. Crowder2010-06-29 14:17:25 +00:00Commented Jun 29, 2010 at 14:17
-
I think he is talking about the REFERER: if visitors come from index.html, alert something. In that case, use the History object.Konerak– Konerak2010-06-29 14:19:28 +00:00Commented Jun 29, 2010 at 14:19
Add a comment
|
2 Answers
if(document.referrer == url){ alert(msg); }
Should do it.
1 Comment
T.J. Crowder
+1 Wow. Had never heard of that, works in Chrome, IE7, and Firefox at least.
Check the referrer, but you most likely will need the absolute uri, like this:
if (document.referrer == 'http://domain.com/index.html')
alert('How was the index?');
1 Comment
Bella
You could of course use the match() method like so if(document.referrer.match("index.php")){ alert(msg) }, but as you rightly say full URL is probably the best idea since it will prevent cross domain matches.