Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax to find the URL of a page

Status
Not open for further replies.

sbind77

Programmer
Joined
Oct 2, 2001
Messages
29
Location
US
Hi

when i entered my address in the address bar
for eg



what is the Syntax in ASP to to get the URL of the page

don't mistake me, If the question is primitive
Thank You
sbind77
 
Sbind,

Run this page and see which one meets your needs. Most of the time, they'll all return the same result.
Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Response.Write &quot;<b>PATH_INFO:</b> &quot; & Request.ServerVariables(&quot;PATH_INFO&quot;) & &quot;<br>&quot;
Response.Write &quot;<b>SCRIPT_NAME:</b> &quot; & Request.ServerVariables(&quot;SCRIPT_NAME&quot;) & &quot;<br>&quot;
Response.Write &quot;<b>URL:</b> &quot; & Request.ServerVariables(&quot;URL&quot;) & &quot;<br>&quot;
%>
If you want the entire URL, including the domain name, I think you're going to have to use JavaScript to do that. Here's an example of how you can post the URL to an ASP page. In this example, we're posting the form to itself, so upon initial loading, the URL will be blank. Just hit the button and you'll see.
Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--
function formCheck(form_ref) {
  form_ref.pageref.value = location.href
  return true
}
//-->
</script>
</head>
<body>
<form method=&quot;post&quot; onSubmit=&quot;return formCheck(this);&quot;>
  <input type=&quot;hidden&quot; value=&quot;&quot; name=&quot;pageref&quot;>
  <input type=&quot;submit&quot; value=&quot;Send URL to ASP&quot;><br><br>
</form>
<b> URL: </b><%=Request.Form(&quot;pageref&quot;)%>
</body>
</html>

Hope this helps..

ToddWW

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top