Get First parameter from url (JavaScript Solution)
Today i ran into problem of how to retrieve the first parameter from a url after "/".
I have designed a simple solution, you can see live demo of it here.
I am also coying the code below
var url = window.location.pathname; // returns the full URL
var splittedurl = url.split('/');
var firstparameter = splittedurl[1]; // returns first parameter after url
alert(firstparameter);
Thanks.
You can ask any question freely in comments.
I have designed a simple solution, you can see live demo of it here.
I am also coying the code below
var url = window.location.pathname; // returns the full URL
var splittedurl = url.split('/');
var firstparameter = splittedurl[1]; // returns first parameter after url
alert(firstparameter);
Thanks.
You can ask any question freely in comments.
Comments
Post a Comment