SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: get current URL?
-
Jun 6, 2006, 12:59 #1
- Join Date
- Feb 2006
- Location
- Altoona, PA. USA
- Posts
- 1,945
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
get current URL?
is there a way i can get the current (relative) url in the broswer?
so say a page is on www.domain.com/folder/file.php it would return folder/file.php
i need to do this so that i can return a user to the previous page they were at after they login.
Thanks.
-
Jun 6, 2006, 13:38 #2
- Join Date
- May 2006
- Location
- Ventura, CA
- Posts
- 2,750
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Could do:
Code:var site_location = document.location.href; return_location = site_location.substring(site_location.indexOf('/'), site_location.length);
-
Jun 6, 2006, 13:47 #3
- Join Date
- Feb 2003
- Location
- Slave I
- Posts
- 23,424
- Mentioned
- 2 Post(s)
- Tagged
- 1 Thread(s)
Kinda curious why you would be doing this with JavaScript and not a server side language.
-
Jun 6, 2006, 13:53 #4
Originally Posted by chris_fuel
Code:function getCurrentURL() { return location.href.slice(location.href.indexOf('/')); }
-
Jun 6, 2006, 14:03 #5
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
document.location.path gets the required piece directly.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Jun 6, 2006, 14:17 #6
- Join Date
- Feb 2006
- Location
- Altoona, PA. USA
- Posts
- 1,945
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by stymiee
-
Jun 6, 2006, 14:19 #7
- Join Date
- Feb 2003
- Location
- Slave I
- Posts
- 23,424
- Mentioned
- 2 Post(s)
- Tagged
- 1 Thread(s)
$_SERVER["PHP_SELF"] holds the path and filename that you are looking for.
-
Jun 6, 2006, 14:24 #8
- Join Date
- Feb 2006
- Location
- Altoona, PA. USA
- Posts
- 1,945
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by stymiee
Bookmarks