Re: parse url information

by "Rajnish Bhaskar" <r.bhaskar(at)compserv.gla.ac.uk>

 Date:  Thu, 18 Apr 2002 14:57:25 +0100
 To:  "Ball,
Steve" <sball(at)providence.org>
 Cc:  hwg-languages(at)hwg.org
 In-Reply-To:  hwg
  todo: View Thread, Original
Hi Steve,

> I want to process a url such as /Folder1/Folder2/Folder3/Pagename How
> can I use  js to derive /Folder1/Folder2/Folder3/ in other words
> truncate the string to the right of the last slash where the amount of
> slashes in the string will vary. Thanks! Steve

Try something like this:

var aUrl = document.location.href;
aUrl = aUrl.substring(0, aUrl.substring(0, aUrl.length-
1).lastIndexOf('/')+1);

Raj.
-- 
Rajnish Bhaskar
r.bhaskar(at)compserv.gla.ac.uk, http://lordofthemoon.com
IT Education Unit, University of Glasgow
http://www.iteu.gla.ac.uk/
--
Only buffoons refer to the Internet as the Information Superhighway.
     -- (The Rough Guide to the Internet 1999)

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.