js query string
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');//get's a query parameter by name from current url
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
//example
var userSearch=getUrlParameter('search_term');
Also in JavaScript:
- nodemon.json env
- laravel open json file in storage
- javascript get intersection of two arrays
- ignore node_modules
- javascript loop object
- momentjs utcoffset
- jquery get value of td by class
- how to debug node js file in webpack
- string charAt array js
- how get height elemnt with that margin in js
- object values javascript
- javascript array add
- deep clone array in javascript
- binary to int javascript
- split a message js
- js redirect to url
- stream recording javascript
- declare array in javascript
- angular how to copy text with button
- return an array of strings from an array of objects js
- chartjs lineTension
- js image on canvas
- Unexpected end of JSON input while parsing near '...fcd15e632426a1be","ta'
- how to make a javascript game