View Full Version : How do I get referring URL?

08-10-2006, 08:29 PM
Hello all. I'm not sure if this is the right place for this question, but here it goes. I have a page (Project.asp) with some script that I don't want to be run if a certain page (Phase.asp) calls it, so, I somehow need to obtain the referring URL and create a statement that 'IF URL != "../Phase.asp" then <run script> END IF". See, when I submit Phase.asp, it is refreshing Project.asp, and therefore running a script that I don't want run at that time.

Here is the portion of Phase.asp calling this page:

opener.parent.main.document.location.href='project.asp?projectid=" & projectId1 & "&autonum=4';

Any ideas how I would obtain this URL?

Thanks in advance,


08-10-2006, 09:30 PM
document.referrer is the field that contains where the web browser said it came from (assuming that the value wasn't changed by the firewall). This field is under user control and so should not be relied on for anything critical.

08-10-2006, 09:39 PM
Thank you for your reply. I found out that I was using referrer, although it liked referer (one 'r') better.

Also, I noticed that since I am using frames, that is causing a little problem, so I just went ahead and added &PhaseAdd=True to the end of the following URL:

opener.parent.main.document.location.href='project.asp?projectid=" & projectId1 & "&autonum=4';

... and on Project.asp, I am just assigning a variable with the value of Request.QueryString("PhaseAdd"), and if the variable <> True, then run the script.

Seems to be working so far.

Thanks again,