Introduction
In our web application sometimes we require current page URL on client side, like when we share any script or perform any action according to the page name.
Code
currentPageUrl = document.location.toString().toLowerCase();
}
else {
currentPageUrl = this.href.toString().toLowerCase();
}
This code also works with the pop ups.
In our web application sometimes we require current page URL on client side, like when we share any script or perform any action according to the page name.
Here I am sharing the demo code to get the current page URL using JavaScript:
Code
var currentPageUrl = "";
if (typeof this.href === "undefined") {currentPageUrl = document.location.toString().toLowerCase();
}
else {
currentPageUrl = this.href.toString().toLowerCase();
}
This code also works with the pop ups.