0

I'm playing around with a Squarespace Website and attempting to search for/get Query string Parameters. No matter what I try with code injection I get null, of course it works fine in the console but not when I use code injection, it is probably something very simple I'm missing, any help would be appreciated.

www.mysite.com?x=123

(function(){

var urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.get('x')); 

})();
  • Does this answer your question? [How to retrieve GET parameters from javascript?](https://stackoverflow.com/questions/5448545/how-to-retrieve-get-parameters-from-javascript) – devnull Feb 11 '20 at 12:02
  • why not simply use `onload` event? https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event – ymz Feb 11 '20 at 12:12
  • @ymz — Because the URL is available immediately. There's no need to wait for anything to load before it can be determined. – Quentin Feb 11 '20 at 14:55

1 Answers1

0

SquareSpace template iFrames in preview version thus it wouldn't work. Starting up local live server was my answer.