SCRIPT5009: 'URLSearchParams' is undefined in IE 11
Odhikari's answer as a (partial) polyfill:
(function (w) {
w.URLSearchParams = w.URLSearchParams || function (searchString) {
var self = this;
self.searchString = searchString;
self.get = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(self.searchString);
if (results == null) {
return null;
}
else {
return decodeURI(results[1]) || 0;
}
};
}
})(window)
If anyone finds this in 2019, corejs now also supports URLSearchParams as a polyfill, so you can just stay with corejs and don't have to brew together something yourselves.
import 'core-js/features/url-search-params';
https://github.com/zloirock/core-js#url-and-urlsearchparams
Got a solution by replacing the code with the following:
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null){
return null;
}
else {
return decodeURI(results[1]) || 0;
}
}
So for example "example.com?param1=name¶m2=&id=6"
$.urlParam('param1'); // name
$.urlParam('id'); // 6
$.urlParam('param2'); // null