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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect page(file) name

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
US
Hi,

Is there a way to get the page or file name with VB or JavaScript that a user is currently on? For instance, ContactUs.htm.

-Uncle Cake
 
via javascript
<html>
<head>
<script language=&quot;JavaScript&quot;>

<!--

/*

This script gets the URL of the current page, then extracts the file name

and path from the URL

*/

var URL = unescape(location.href) // get current URL in plain ASCII



var xstart = URL.lastIndexOf(&quot;/&quot;) + 1

var xend = URL.length

var hereName = URL.substring(xstart,xend)

var herePath = URL.substring(0,xstart)



document.write(&quot;The name of the current file is: &quot; + hereName)

document.write(&quot;The path of the current file is: &quot; + herePath)

// -->

</script>
</head>
<body>
</body>
</html>

URL From
Was it something I said?
admin@onpntwebdesigns.com
 
Thanks onpnt, I think that this will work!

-Uncle Cake
 
Via VBscript and ASP:

<%
url = request.servervariables(&quot;HTTP_HOST&quot;) & &quot;/&quot; & request.servervariables(&quot;URL&quot;)
response.write url
%>

Much easier.



-Phil
fillup07@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top