0

How can I get the URL parameters of the current page? This is for a userscript that I want to redirect the user to a different url if current url parameter equals a predefined parameter. I want the script to loop between 3 set pages.

The urls look like this: example.com/pages?car=1

I have no idea whatsoever how to do this, but this is somewhat how

if(url is ?car=1){
   wait 5 seconds;
   redirect to ?car=2;
}elseif(url is ?car=2){
   wait 5 seconds;
   redirect to ?car=3;
}elseif(url is ?car=3){
   wait 5 seconds;
   redirect to ?car=1;
}
Hans
  • 33
  • 1
  • 5

1 Answers1

0

You can use window.location to redirect the user to different url

And read this to get the values from query string.

How can I get query string values in JavaScript?

Community
  • 1
  • 1
ysrb
  • 6,693
  • 2
  • 29
  • 30