“Permintaan pencarian di JavaScript” Kode Jawaban

Dapatkan URL Query Params JS

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

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

Permintaan pencarian di JavaScript

 const { search } = useLocation()
const redireactURL = new URLSearchParams(search).get('redirect')
const redirect = redireactURL ? redireactURL : '/'

---------------------
/*
const params = new URLSearchParams(window. location. search)
params. has('test')
params. get('test')
const params = new URLSearchParams(window. location. search) for (const param of params) { console. log(param) }
*/
Rasel Hossain

Jawaban yang mirip dengan “Permintaan pencarian di JavaScript”

Pertanyaan yang mirip dengan “Permintaan pencarian di JavaScript”

Lebih banyak jawaban terkait untuk “Permintaan pencarian di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya