QueryString and referencing anchors in the URL

B

bradeck

I have a need to pass a url via the address field to a page - i.e.
page.asp?myurl=newpage.asp.

When I get the QueryString object for "myurl" it correctly comes back
with 'newpage.asp'. However, if I pass an anchor name on the url -
e.g. page.asp?myurl=newpage.asp#myanchor - the result is still just
'newpage.asp'.

Is there a way to pass the anchor link into the page and get access to
it?
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
I have a need to pass a url via the address field to a page - i.e.
page.asp?myurl=newpage.asp.

When I get the QueryString object for "myurl" it correctly comes back
with 'newpage.asp'. However, if I pass an anchor name on the url -
e.g. page.asp?myurl=newpage.asp#myanchor - the result is still just
'newpage.asp'.

Is there a way to pass the anchor link into the page and get access to
it?

I don't think so, because it is client side and ASP does not know about
client side. I know it is not possible in PHP.
 
E

Evertjan.

Adrienne Boswell wrote on 04 jun 2007 in
microsoft.public.inetserver.asp.general:
Gazing into my crystal ball I observed (e-mail address removed) writing in


I don't think so, because it is client side and ASP does not know about
client side. I know it is not possible in PHP.

You will have to translate it to:

page.asp?myurl=newpage.asp^myanchor

a otherwise the browser will think the
#myanchor
part is ment for
page.asp
and not of
newpage.asp:


============== original.asp ==============

<%
theURLStr = "page.asp?myurl=newpage.asp#myanchor"
theURLStr = replace(theURLStr,"#","^"))
%>
<a href='<%= theURLStr %>'>to page.asp</a>

===========================================

============== page.asp ===================

<%
theURLStr = request.querystring("myurl")
theURLStr = replace(theURLStr,"^","#"))
%>
<a href='<%= theURLStr %>'>to newpage.asp with #myanchor</a>

===========================================
 
D

Dave Anderson

Evertjan. said:
You will have to translate it to:

page.asp?myurl=newpage.asp^myanchor

a otherwise the browser will think the
#myanchor
part is ment for
page.asp
and not of
newpage.asp:

If there is an unencoded "#" in the URL that is not part of a character
entity, it IS intended for the client. The browser does not merely *think*
so. It is obeying RFC 1808...

2.4.1. Parsing the Fragment Identifier

If the parse string contains a crosshatch "#" character, then the
substring after the first (left-most) crosshatch "#" and up to the
end of the parse string is the <fragment> identifier. If the
crosshatch is the last character, or no crosshatch is present, then
the fragment identifier is empty. The matched substring, including
the crosshatch character, is removed from the parse string before
continuing.

Note that the fragment identifier is not considered part of the URL.
However, since it is often attached to the URL, parsers must be able
to recognize and set aside fragment identifiers as part of the
process.


....not to mention RFC 1738:

2.2. URL Character Encoding Issues

All unsafe characters must always be encoded within a URL. For
example, the character "#" must be encoded within URLs even in
systems that do not normally deal with fragment or anchor
identifiers, so that if the URL is copied into another system that
does use them, it will not be necessary to change the URL encoding.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top