WHAT'S MY PARAMETER?

Need to read, find and get parameter value(s) from a URL string of a current page and/or email newsletter to be able to perform some type of action? We'll here ya go...

INSTALL

To install, add the below code into the page(s) you wish to collect parameter data on.

STEP 1: Install jQuery

<
script
src
=
"https://code.jquery.com/jquery-2.2.0.min.js"
><
/script
>

STEP 2: Attach parameter that you want to check.

<
a
href
=
"https://www.example.com?test=abc"
> Hyperlink <
/a
>

STEP 3: Then copy&paste the wmParameter

function
wmParameter
(
findParam
){

  var
pageURL
=
window
.location.search.substring(
1
);

  var
splitURL
=
pageURL
.split(
'&'
);

  for
(
var
i
=
0
;
i
<
splitURL
.length;
i
++){

    var
paramName
=
splitURL
[
i
].split(
'='
);

    if
(
paramName
[
0
] ===
findParam
){

      return
paramName
[
1
];

    }

  }

}


var
thisParameter
=
wmParameter
(
"test"
);


if
(
thisParameter
===
"abc"
){

  alert
(
thisParameter
);

}
else
{

  alert
(
"null"
);

}

STEP 4: If successful, replace with your jQuery action.

$
(
"element"
).method(
"property"
);
danielmdesigns.com