lfischer

ThomasCook - getParameter

Aug 30th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Parse the URL and gives the value for a given key
  2. function getParameterByName(name) {
  3.     name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  4.     var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  5.         results = regex.exec(location.search);
  6.     return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  7. }
Advertisement
Add Comment
Please, Sign In to add comment