I got three pages a,b,c point to same page d when clicking submit.
Is there any way, by using JavaScript to trace back which page a or b or
c to reach it, once exit button is clicked on page d?
You can trace what page sent the value by adding a name/value pair to the
query string when you transmit the page. The value could either by a
unique string or the path/filename of the referring document.
Of course, it's not a good idea to hinge page functionality on a script;
you can apply what I'm about to say on the server, too.
Getting the value that was inserted into the query string is fairly
trivial.
var i, ref;
if((i = location.search.indexOf('name=')) != -1) {
ref = location.search.substring(i + 5, i + 5 + length);
}
Getting the correct value of 'length' depends on what values you use. If
the values are all of the same length, then it's simple. If it's a
variable string, then you'd need something like:
var i, j, ref, s = location.search;
if((i = s.indexOf('name=')) != -1) {
/* Find delimiter of next pair. If not
* found, extract up to end of string. */
if((j = s.indexOf('&', i)) == -1) {j = s.length;}
ref = s.substring(i + 5, j);
}
In either case, replace 'name' as appropriate.
I haven't tested either of the solutions above but they should work.
Hope that helps,
Mike