SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Mar 29, 2005, 13:41 #1
- Join Date
- Nov 2002
- Location
- Scottsdale, Arizona, USA
- Posts
- 603
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Q: Take end part of document.referrer
If I have the url 'http://www.myurl.com/section/about_us.php' is there a way (I'm thinking the best is via document.referrer) to only grab 'about_us.php' I'm thinking if there was a way to take everything from the end to the first / then it would work. Is something like this possible?
I basically want to grab my content pages so I can stick them in a different interface and to do this I need just the end part of the url.
Thanks!
-
Mar 29, 2005, 21:41 #2
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm thinking if there was a way to take everything from the end to the first / then it would work. Is something like this possible?
Code:var str = 'http://www.myurl.com/section/about_us.php'; var start = str.lastIndexOf("/") + 1; var page = str.substring(start); alert(page);
-
Mar 30, 2005, 16:02 #3
- Join Date
- Nov 2002
- Location
- Scottsdale, Arizona, USA
- Posts
- 603
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sweet! Thanks for the help
.
-
Mar 30, 2005, 23:55 #4
- Join Date
- Jan 2005
- Location
- Outerspace
- Posts
- 511
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is another way that will allow you to gain a millisecond
)
Code:var str = 'http://www.myurl.com/section/about_us.php'; var page = str.split("\/")[str.split("\/").length-1] alert(page);
-
Mar 31, 2005, 01:09 #5
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by SpaceFrog
-
Mar 31, 2005, 01:25 #6
- Join Date
- Jan 2005
- Location
- Outerspace
- Posts
- 511
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well at least my method allows also to retrieve every folder level of path ...
how many points is that worth ?
Bookmarks