First of all, look at this example.Then you can understand this better.
Get specific characters from a url
//url like = http://www.example.com/category.php?id=12 var currentURL = window.location; var chars = currentURL.href.substr(-2); alert(chars); // 12
How can you get url parameters from url?
//url like = http://www.example.com/category.php?id=12&action=edit param = document.location.href.split('?'); alert(param); // id=12&action=edit
Get specific characters from a given string or text.
If you want to get last two characters from a string, you can get it like following example.
var charList = "This is an example"; var lastTwo = charList.substr(charList.length - 2); alert(lastTwo);
Following example is describes how is the behavior of sub string.This is get start from 2nd letter(here “a”) with get number of three characters.
var charList = "example"; alert(charList.substr(2,3));
var myString = 'colomn1_Tabs1'; var lastFive = myString.substr(-5); // get from last "Tabs1" alert(lastFive);