How to get the current page URL (URL) and query parameters
Get the current page URL (URL) and query parameters in JavaScript.
Sometimes we need to get the URL parameters for the current page on the client, and you probably know that it's easier to get it on the server side, such as PHP or JSP, but it's simpler in JavaScript.
Let's take a look at the URLs shown below:
Http://www.webfans.org/index.php?query.
The previous section is the current URL for the page, http://www.webfans.org/, which we call query parameters.
To get the URL address of the current page just use the following code: < script language = ' JavaScript ' >
var Currenturl = this. Location.href
</script > Of course, the above method can also change the URL of a page to achieve the orientation of the page.
Get the query parameters, which are the following code. < SCRIPT language = ' JavaScript ' >
var currentquery = this. Location.search.
</script >