05 July, 2008, 07:08:20 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: We Return!
 

Pages: [1]   Go Down
  Print  
Author Topic: Splitting location url  (Read 187 times)
0 Members and 1 Guest are viewing this topic.
United States
Long live TCZ

TCZ r0x my s0x

Administrator

Platinum Contribution
*
Conqueror

Karma: 70
Offline Offline

Gender: Male
Posts: 4689
679832.36 Secksi Coins

View Inventory
Send Money to slayer766

View Profile
« on: 25 April, 2008, 07:32:18 PM »
Knock knock knocking on heaven's door...

Ok I'm going to explain just a little bit on how you can split your location url into seperate sets of data which you will be able to access easily...

Well this code will split your url into an array, which you can access easily from 1 variable:

Code:
<script type="text/javascript">
if(location.href.match(/http:\/\/(.*)/i)){
data = RegExp.$1.split(/\//i);
}
alert(data[0]);
</script>

Here we are just basically splitting the url into an array of separate pieces. Which would alert the first separate set of your location.

If we were to use your example of "http://phantom-designs.net/index.php?showuser=331/marketplace/id/wow" this is how the code would work:

The variable data in the above code now contains each section of the url but split up, you can access each of these different sets by giving the variable a specific number like so:

Saying data[0] would output the section of your location of "phantom-designs.net"
Saying data[3] would output the section of your location of "id"

So basically the url would virtually look like this:

"http://data[ 0]/data[1]/data[2]/data[3]/data[4]"

Using any of those would output what you have chosen in the set. Anything else added to that existing url would just extend those numbers by 1 each time. Smiley
Logged

Live for nothing or die for something




This resource was found useful by 0 out of 0 members. Rate it: [applaud] [smite]
Pages: [1]   Go Up
  Print  
 
Jump to:  
Sponsored Links:

Powered by MySQL
Powered by PHP
Powered by SMF 1.1.1 | SMF © 2005, Simple Machines LLC
TinyPortal v0.8.6 © Bloc
The rest copyright TCZ you pillocking twat!
Valid XHTML 1.0!
Valid CSS!
Places we'd like you to visit.