Obtaining URL of previous page

M

middletree

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.
 
M

middletree

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?
 
A

Aaron Bertrand - MVP

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/
 
D

Dave Anderson

Aaron said:
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.
 
A

Aaron Bertrand - MVP

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
 
D

Dave Anderson

I said:
<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.
 
E

Evertjan.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top