Re: Determine if path is absolute or relative

Tech-Archive recommends: Fix windows errors by optimizing your registry



Giles wrote on 17 nov 2007 in microsoft.public.scripting.jscript:

Is there a simple JS function to determine if a path is absolute or
relative, that works for both local and web paths? picking up :// is
easy enough, but the path may be local, like d:\mydir\subdir\ (instead
of file:///d:/mydir/subdir/ ). Or it may be a share...


If you mean by "a path" "a string containing a path"

alert((/:/.test(myString))?'absolute':'relative')

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
.