PDA

View Full Version : retrieving index details from url


tame4tex
06-06-2005, 02:51 AM
The code below takes the script name of a page (which is always an asp file) and substitutes the asp extension with html and then inserts the file in the <frame> tag.

This code works file for a url such as
www.somesite.com/file.asp
But if the url includes an index eg
www.somesite.com/file.asp#position1
how do I get the #position1 added to the file name that is used in the <frame> tag?

Is there a server variable for # info?

Any help would be greatly appreciated!

<%

dim fname
fname=Request.ServerVariables("script_name")
fname=Replace(fname, "asp", "html")

%>


<FRAMESET Rows="33,*,50" Border=0 Frameborder=0 Framemargin=0>
<FRAME SRC="/header.asp" NAME="header" Marginheight=0 Marginwidth=0 Scrolling=no>
<% response.write("<FRAME SRC='" & fname & "' NAME='main' Marginheight=0 Marginwidth=0 Scrolling=auto>") %>
<FRAME SRC="/footer.asp" NAME="footer" Marginheight=0 Marginwidth=0 Scrolling=no>
</FRAMESET>

glenngv
06-06-2005, 06:14 AM
The # in the URL seems to be not passed to the server because the ServerVariables collection doesn't have it. Running this code with a # in the URL will not include that information.
<%
for each item in request.servervariables
response.write item & "=" & request.servervariables(item) & "<br />"
next
%>
So, you're only left with a client-side (javascript) solution.
<%
dim fname
fname=Request.ServerVariables("script_name")
fname=Replace(fname, "asp", "html")
%>
<html>
<head>
<title></title>
<script type="text/javascript">
window.onload = function(){
window.frames['main'].location.hash = top.location.hash;
}
</script>
</head>
<FRAMESET Rows="33,*,50" Border=0 Frameborder=0 Framemargin=0>
<FRAME SRC="/header.asp" NAME="header" Marginheight=0 Marginwidth=0 Scrolling=no>
<% response.write("<FRAME SRC='" & fname & "' NAME='main' Marginheight=0 Marginwidth=0 Scrolling=auto>") %>
<FRAME SRC="/footer.asp" NAME="footer" Marginheight=0 Marginwidth=0 Scrolling=no>
</FRAMESET>
</html>

tame4tex
06-11-2005, 06:33 AM
worked perfectly...thank you!!!