Get Query String Parameters with JavaScript
We've always been able to get the full query string via the window.location.search
property:
console.log(window.location.search); // "?post=1234&action=edit"
...but in a world of setters, getters, and JSON, there must be a better way to get values than parsing a string, right? After years of ugly string parsing, there's a better way: URLSearchParams
Let's have a look at how we can use this new API to get values from the location!
Read full article from Get Query String Parameters with JavaScript
No comments:
Post a Comment