Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    215
    Thanks
    14
    Thanked 0 Times in 0 Posts

    How do I get referring URL?

    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:

    PHP Code:
    <SCRIPT LANGUAGE="JAVASCRIPT">
    opener.parent.main.document.location.href='project.asp?projectid=" & projectId1 & "&autonum=4';
    window.close();
    </script> 
    Any ideas how I would obtain this URL?

    Thanks in advance,

    Parallon
    Last edited by parallon; 08-10-2006 at 07:32 PM.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    215
    Thanks
    14
    Thanked 0 Times in 0 Posts
    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,

    Parallon


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •