Generation

generate functionMon, 16 Jan 2023

Crie uma função javascript que pegue todos os parâmetros na URL.

function getUrlParams(url){ var params = {}; var parser = document.createElement('a'); parser.href = url; var query = parser.search.substring(1); var vars = query.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split('='); params[pair[0]] = decodeURIComponent(pair[1]); } return params; }; getUrlParams('http://andrefs.com/page.html?name=andrefs&occupation=developer');

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant