469,287 Members | 2,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

Obtaining URL of previous page

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.

Jul 19 '05 #1
11 7610
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" <mi********@htomail.com> wrote in message
news:#Z**************@TK2MSFTNGP11.phx.gbl...
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.

Jul 19 '05 #2
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" <mi********@htomail.com> wrote in message
news:#Z**************@TK2MSFTNGP11.phx.gbl...
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.

Jul 19 '05 #3
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" <aa***@TRASHaspfaq.com> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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" <mi********@htomail.com> wrote in message
news:#Z**************@TK2MSFTNGP11.phx.gbl...
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.


Jul 19 '05 #4
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" <mi********@htomail.com> wrote in message
news:uu*************@TK2MSFTNGP11.phx.gbl...
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" <aa***@TRASHaspfaq.com> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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" <mi********@htomail.com> wrote in message
news:#Z**************@TK2MSFTNGP11.phx.gbl...
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.



Jul 19 '05 #5
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.
Jul 19 '05 #6
> 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
Jul 19 '05 #7
I updated the article so it is less ambiguous.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #8
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.
Jul 19 '05 #9
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)
Jul 19 '05 #10
<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>
Jul 19 '05 #11
<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>
Jul 19 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Marcel | last post: by
1 post views Thread by Terry Mulvany | last post: by
6 posts views Thread by honguin | last post: by
13 posts views Thread by staeri | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.