How to get current url [Resolved]

Posted by Nksingh420 under ASP.NET on 1/27/2014 | Points: 10 | Views : 1677 | Status : [Member] | Replies : 2
my current url is >http://localhost:2828/Employee/EmployeeList?EId=null


how to get current url using java script

if i use window.location.pathname it givs only "Employee/EmployeeList"

if i use window.location.href it givs "http://localhost:2828/Employee/EmployeeList?EId=null"

i want "Employee/EmployeeList?EId=null" any solution




Responses

Posted by: kgovindarao523-21772 on: 1/27/2014 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Here is the javascript code:
Please Mark as Answer if you got it.
function myfunction()
{
var mainUrl = window.location.href;
var filteredUrl = mainUrl.replace("http://", "");
var firstSlashPosition = filteredUrl.indexOf('/');
var currentUrl = filteredUrl.substr(parseInt(firstSlashPosition) + 1, filteredUrl.length);
alert(currentUrl);
}


Thank you,
Govind

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 1/27/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Use location.href to get current URL in javascript.

Nksingh420, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response