“Dapatkan kueri param javascript” Kode Jawaban

JS Dapatkan Param kueri

const queryString = window.location.search;
const parameters = new URLSearchParams(queryString);
const value = parameters.get('key');
MCRC

Dapatkan kueri param javascript

const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');
Faithful Falcon

Dapatkan URL Query Params JS

const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');
Embarrassed Elephant

JavaScript Reading Query Parameter

// example url: https://mydomain.com/?fname=johnny&lname=depp
const urlParams = new URLSearchParams(window.location.search);
const firstName = urlParams.get('fname'); // johnny
Scriper

JavaScript mendapatkan parameter kueri

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, ' '));
};
Grepper

JavaScript mendapatkan kueri param dari url

const getParameters = (URL) => {
  URL = JSON.parse('{"' + decodeURI(URL.split("?")[1]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') +'"}');
  return JSON.stringify(URL);
};

getParameters(window.location)
// Result: { search : "easy", page : 3 }
Rashid Siddique

Jawaban yang mirip dengan “Dapatkan kueri param javascript”

Pertanyaan yang mirip dengan “Dapatkan kueri param javascript”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya