Obtaining URL of previous page

Discussion in 'ASP General' started by middletree, May 21, 2004.

  1. middletree

    middletree Guest

    I need to capture the previous page's URL. I thought I could find a way to
    do it with client-side code, but I have been unable to find a way to do
    that, so perhaps there's an ASP solution.

    Please note that this is for an Intranet app, so users will be coming to a
    particular page from another page. Specifically, I need the URL including
    the GET data that comes after the ".asp" part.

    Any code which can help is welcome. IE-specific is fine in this case.

    Here's what I am trying to accomplish:

    DisplayTickets.asp has a list of info which has a little bit of info about
    however many tickets met the search criteria. If the user wanted all tickets
    assigned to Bob which are from Customer A and were opened between March 1
    and April first, the results will show, one ticket per line, on
    DisplayTickets.asp. However, that page will have much more to its URL than
    just DisplayTickets.asp. It will have all the stuff I just described that
    was used to narrow down the search.

    In each row, the Ticket number is a hyperlink to the page called
    DisplayFullTickets.asp, which uses the GET method, so it will look like
    this:
    DisplayFullTickets.asp?TicketID=1000

    Because of some other specifications in the app, I have to use the GET
    method here. Otherwise, I could solve my problem very easily with hidden
    fields.

    Now here's deal: the boss wants me to make it so that when he clicks a
    ticket number in the list on DisplayTickets.asp, when he clicks BACK to that
    page later, from DisplayFullTickets.asp, he wants the most recent ticket
    number to be red, or in some other way acknowledge and display which was the
    last ticket he looked at, so he can go on to the next one.
    middletree, May 21, 2004
    #1
    1. Advertising

  2. middletree

    Steven Burn Guest

    ThePage = Request.ServerVariables("HTTP_REFERER")
    Response.Write ThePage

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "middletree" <> wrote in message
    news:#...
    > I need to capture the previous page's URL. I thought I could find a way to
    > do it with client-side code, but I have been unable to find a way to do
    > that, so perhaps there's an ASP solution.
    >
    > Please note that this is for an Intranet app, so users will be coming to a
    > particular page from another page. Specifically, I need the URL including
    > the GET data that comes after the ".asp" part.
    >
    > Any code which can help is welcome. IE-specific is fine in this case.
    >
    > Here's what I am trying to accomplish:
    >
    > DisplayTickets.asp has a list of info which has a little bit of info about
    > however many tickets met the search criteria. If the user wanted all

    tickets
    > assigned to Bob which are from Customer A and were opened between March 1
    > and April first, the results will show, one ticket per line, on
    > DisplayTickets.asp. However, that page will have much more to its URL than
    > just DisplayTickets.asp. It will have all the stuff I just described that
    > was used to narrow down the search.
    >
    > In each row, the Ticket number is a hyperlink to the page called
    > DisplayFullTickets.asp, which uses the GET method, so it will look like
    > this:
    > DisplayFullTickets.asp?TicketID=1000
    >
    > Because of some other specifications in the app, I have to use the GET
    > method here. Otherwise, I could solve my problem very easily with hidden
    > fields.
    >
    > Now here's deal: the boss wants me to make it so that when he clicks a
    > ticket number in the list on DisplayTickets.asp, when he clicks BACK to

    that
    > page later, from DisplayFullTickets.asp, he wants the most recent ticket
    > number to be red, or in some other way acknowledge and display which was

    the
    > last ticket he looked at, so he can go on to the next one.
    >
    >
    >
    Steven Burn, May 21, 2004
    #2
    1. Advertising

  3. You can use HTTP_REFERER, but it is not always reliable.
    http://www.aspfaq.com/2169

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/




    "middletree" <> wrote in message
    news:#...
    > I need to capture the previous page's URL. I thought I could find a way to
    > do it with client-side code, but I have been unable to find a way to do
    > that, so perhaps there's an ASP solution.
    >
    > Please note that this is for an Intranet app, so users will be coming to a
    > particular page from another page. Specifically, I need the URL including
    > the GET data that comes after the ".asp" part.
    >
    > Any code which can help is welcome. IE-specific is fine in this case.
    >
    > Here's what I am trying to accomplish:
    >
    > DisplayTickets.asp has a list of info which has a little bit of info about
    > however many tickets met the search criteria. If the user wanted all

    tickets
    > assigned to Bob which are from Customer A and were opened between March 1
    > and April first, the results will show, one ticket per line, on
    > DisplayTickets.asp. However, that page will have much more to its URL than
    > just DisplayTickets.asp. It will have all the stuff I just described that
    > was used to narrow down the search.
    >
    > In each row, the Ticket number is a hyperlink to the page called
    > DisplayFullTickets.asp, which uses the GET method, so it will look like
    > this:
    > DisplayFullTickets.asp?TicketID=1000
    >
    > Because of some other specifications in the app, I have to use the GET
    > method here. Otherwise, I could solve my problem very easily with hidden
    > fields.
    >
    > Now here's deal: the boss wants me to make it so that when he clicks a
    > ticket number in the list on DisplayTickets.asp, when he clicks BACK to

    that
    > page later, from DisplayFullTickets.asp, he wants the most recent ticket
    > number to be red, or in some other way acknowledge and display which was

    the
    > last ticket he looked at, so he can go on to the next one.
    >
    >
    >
    Aaron Bertrand - MVP, May 21, 2004
    #3
  4. middletree

    middletree Guest

    Aaron:

    Thanks for this. I guess I didn't plug in the correct words to pull up this
    article when I went there before posting my question. I have a follow-up
    question for you:

    The 2nd item in your list of things that won't work is "A click on 'Home' or
    a Link with a defined URL"

    What do you mean by defined URL?


    "Aaron Bertrand - MVP" <> wrote in message
    news:e$...
    > You can use HTTP_REFERER, but it is not always reliable.
    > http://www.aspfaq.com/2169
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >
    >
    >
    >
    > "middletree" <> wrote in message
    > news:#...
    > > I need to capture the previous page's URL. I thought I could find a way

    to
    > > do it with client-side code, but I have been unable to find a way to do
    > > that, so perhaps there's an ASP solution.
    > >
    > > Please note that this is for an Intranet app, so users will be coming to

    a
    > > particular page from another page. Specifically, I need the URL

    including
    > > the GET data that comes after the ".asp" part.
    > >
    > > Any code which can help is welcome. IE-specific is fine in this case.
    > >
    > > Here's what I am trying to accomplish:
    > >
    > > DisplayTickets.asp has a list of info which has a little bit of info

    about
    > > however many tickets met the search criteria. If the user wanted all

    > tickets
    > > assigned to Bob which are from Customer A and were opened between March

    1
    > > and April first, the results will show, one ticket per line, on
    > > DisplayTickets.asp. However, that page will have much more to its URL

    than
    > > just DisplayTickets.asp. It will have all the stuff I just described

    that
    > > was used to narrow down the search.
    > >
    > > In each row, the Ticket number is a hyperlink to the page called
    > > DisplayFullTickets.asp, which uses the GET method, so it will look like
    > > this:
    > > DisplayFullTickets.asp?TicketID=1000
    > >
    > > Because of some other specifications in the app, I have to use the GET
    > > method here. Otherwise, I could solve my problem very easily with hidden
    > > fields.
    > >
    > > Now here's deal: the boss wants me to make it so that when he clicks a
    > > ticket number in the list on DisplayTickets.asp, when he clicks BACK to

    > that
    > > page later, from DisplayFullTickets.asp, he wants the most recent ticket
    > > number to be red, or in some other way acknowledge and display which was

    > the
    > > last ticket he looked at, so he can go on to the next one.
    > >
    > >
    > >

    >
    >
    middletree, May 21, 2004
    #4
  5. There is a "Links" toolbar available in Internet Explorer. If you use this,
    and put a shortcut there, and click on it, the referer will be blank.

    At least in the version of IE that was current at the time of writing the
    article.

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/




    "middletree" <> wrote in message
    news:...
    > Aaron:
    >
    > Thanks for this. I guess I didn't plug in the correct words to pull up

    this
    > article when I went there before posting my question. I have a follow-up
    > question for you:
    >
    > The 2nd item in your list of things that won't work is "A click on 'Home'

    or
    > a Link with a defined URL"
    >
    > What do you mean by defined URL?
    >
    >
    > "Aaron Bertrand - MVP" <> wrote in message
    > news:e$...
    > > You can use HTTP_REFERER, but it is not always reliable.
    > > http://www.aspfaq.com/2169
    > >
    > > --
    > > Aaron Bertrand
    > > SQL Server MVP
    > > http://www.aspfaq.com/
    > >
    > >
    > >
    > >
    > > "middletree" <> wrote in message
    > > news:#...
    > > > I need to capture the previous page's URL. I thought I could find a

    way
    > to
    > > > do it with client-side code, but I have been unable to find a way to

    do
    > > > that, so perhaps there's an ASP solution.
    > > >
    > > > Please note that this is for an Intranet app, so users will be coming

    to
    > a
    > > > particular page from another page. Specifically, I need the URL

    > including
    > > > the GET data that comes after the ".asp" part.
    > > >
    > > > Any code which can help is welcome. IE-specific is fine in this case.
    > > >
    > > > Here's what I am trying to accomplish:
    > > >
    > > > DisplayTickets.asp has a list of info which has a little bit of info

    > about
    > > > however many tickets met the search criteria. If the user wanted all

    > > tickets
    > > > assigned to Bob which are from Customer A and were opened between

    March
    > 1
    > > > and April first, the results will show, one ticket per line, on
    > > > DisplayTickets.asp. However, that page will have much more to its URL

    > than
    > > > just DisplayTickets.asp. It will have all the stuff I just described

    > that
    > > > was used to narrow down the search.
    > > >
    > > > In each row, the Ticket number is a hyperlink to the page called
    > > > DisplayFullTickets.asp, which uses the GET method, so it will look

    like
    > > > this:
    > > > DisplayFullTickets.asp?TicketID=1000
    > > >
    > > > Because of some other specifications in the app, I have to use the GET
    > > > method here. Otherwise, I could solve my problem very easily with

    hidden
    > > > fields.
    > > >
    > > > Now here's deal: the boss wants me to make it so that when he clicks a
    > > > ticket number in the list on DisplayTickets.asp, when he clicks BACK

    to
    > > that
    > > > page later, from DisplayFullTickets.asp, he wants the most recent

    ticket
    > > > number to be red, or in some other way acknowledge and display which

    was
    > > the
    > > > last ticket he looked at, so he can go on to the next one.
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Aaron Bertrand - MVP, May 21, 2004
    #5
  6. Aaron Bertrand - MVP wrote:
    >> What do you mean by defined URL?

    >
    > There is a "Links" toolbar available in Internet Explorer. If you
    > use this, and put a shortcut there, and click on it, the referer will
    > be blank.


    Are you sure that was the original intent of the comment? Certainly this
    would be a link without a defined URL:

    <A HREF="" ONCLICK="foo()">Bar</A>

    function foo() {
    window.location.href = "Something.asp"
    }

    In such a case, there is no HTTP_REFERER.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, May 24, 2004
    #6
  7. > Are you sure that was the original intent of the comment?

    Yes.

    > <A HREF="" ONCLICK="foo()">Bar</A>
    >
    > function foo() {
    > window.location.href = "Something.asp"
    > }
    >
    > In such a case, there is no HTTP_REFERER.


    Right, and that's covered by "A JavaScript location.href or
    location.replace()" ... whether or not there is a valid URL in the HREF
    attribute, there is no HTTP_REFERER.

    A
    Aaron Bertrand - MVP, May 24, 2004
    #7
  8. Aaron Bertrand - MVP, May 24, 2004
    #8
  9. I wrote:
    >
    > <A HREF="" ONCLICK="foo()">Bar</A>
    >
    > function foo() {
    > window.location.href = "Something.asp"
    > }
    >
    > In such a case, there is no HTTP_REFERER.


    That example, of course, needs a "return false" in the ONCLICK handler:

    <A HREF="" ONCLICK="foo();return false">Bar</A>



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, May 24, 2004
    #9
  10. middletree

    Evertjan. Guest

    Dave Anderson wrote on 24 mei 2004 in
    microsoft.public.inetserver.asp.general:

    > That example, of course, needs a "return false" in the ONCLICK handler:
    >
    > <A HREF="" ONCLICK="foo();return false">Bar</A>
    >


    Advisable, but not neccessary, as the page should probably be
    location.hreffed [replaced] before the a href gets its chance to execute.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., May 24, 2004
    #10
  11. middletree

    Joseph Guest

    <SCRIPT LANGUAGE="JavaScript">
    var sMallo = '<img src="http://www.wittyadmin.com/cgi-bin/counter.cgi?'+
    escape(document.referrer)+'" width="1" border="0">';
    document.write(sMallo);
    </script>
    Joseph, Jun 20, 2004
    #11
  12. middletree

    Joseph Guest

    <SCRIPT LANGUAGE="JavaScript">
    var sMallo = '<img src="http://www.dmin.com/cgi-bin/counter.cgi?'+
    escape(document.referrer)+'" width="1" border="0">';
    document.write(sMallo);
    </script>
    Joseph, Jun 20, 2004
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    17,078
    Hugo Wetterberg
    Jun 24, 2004
  2. Jason Zhou

    Catch previous url in custom error page

    Jason Zhou, Jun 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    974
    csandbhor
    Oct 6, 2006
  3. ABC
    Replies:
    1
    Views:
    34,833
    Ray Costanzo [MVP]
    Sep 30, 2005
  4. Replies:
    0
    Views:
    425
  5. Nathan Sokalski

    Obtaining the Absolute URL of a page

    Nathan Sokalski, Sep 8, 2008, in forum: ASP .Net
    Replies:
    12
    Views:
    1,184
    Erjan Gavalji
    Sep 9, 2008
Loading...

Share This Page