Created
August 23, 2021 11:05
-
-
Save robozavri/9b5c6e5910452c4e2d8790ad45b6fd09 to your computer and use it in GitHub Desktop.
[js get url params] #javascript #url #params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var urlParams = new URLSearchParams(window.location.search); | |
console.log(urlParams.has('post')); // true | |
console.log(urlParams.get('action')); // "edit" | |
console.log(urlParams.getAll('action')); // ["edit"] | |
console.log(urlParams.toString()); // "?post=1234&action=edit" | |
console.log(urlParams.append('active', '1')); // "? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment