By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Javascript document location

P: n/a
I'm not very experienced with Javascript, and I'm trying to determin a
current web page's path. If I use document.location, it returns
http://domain.com/path/to/file
I only want to see /path/to/file

How do I do this?

Dec 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Graham wrote:
I'm not very experienced with Javascript, and I'm trying to determin a
current web page's path. If I use document.location,
.... which is deprecated long since, ...
it returns
http://domain.com/path/to/file
I only want to see /path/to/file

How do I do this?


window.location.pathname

Be aware that this is no longer part of the JavaScript language since
version 1.4 (and has never been in JScript) but instead part of the DOM
of the UA. An UA may or may not implement it, so you should test for it.
And of course enabled client-side script support is required for it.
PointedEars
Dec 18 '05 #2

P: n/a
document.location.pathname worked perfectly (I didn't try
window.location.pathname).

Thanks fo much!

Dec 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.