×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Diego Zanandrea
Added: Nov 25, 2017 6:01 PM
Views: 2
Obtener parámetro desde la URL
  1. function getParameterByName(name, url) {
  2.     if (!url) url = window.location.href;
  3.     name = name.replace(/[\[\]]/g, "\\$&");
  4.     var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
  5.         results = regex.exec(url);
  6.     if (!results) return null;
  7.     if (!results[2]) return '';
  8.     return decodeURIComponent(results[2].replace(/\+/g, " "));
  9. }