tags:

views:

57

answers:

2

is it possible to in javascript like in php header location, if the visitor comes from index html alert something? and how ? thank you

+2  A: 
if(document.referrer == url){ alert(msg); }

Should do it.

DRL
+1 Wow. Had never heard of that, works in Chrome, IE7, and Firefox *at least*.
T.J. Crowder
+2  A: 

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?');
Alan Christopher Thomas
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.
DRL