This one is a redirection code, I used it without any url parameters, but now I need it to work according to the parameters and I could not, I'm pretty new to javascript, could anyone explain what I'm doing wrong in my code?
If ver
is equal to 1
, do nothing, otherwise run window.location.replace("https://www.google.com");
var url = new URL(window.location);
var ver = url.searchParams.get("ver");
document.onload = function() {
if(ver == 1) {
return false;
}
else {
window.location.replace("https://www.google.com");
}
}