2
This one is a redirect code, I used it without url parameters, but now I need it to work according to the parameters and I could not, I am very new in javascript, could someone explain to me what I am 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");
}
}
can explain to me the function of exclamation?
– user120323
Yes:
!=
means "different" and==
means "equal"– Sam
thank you very much, this will help me simplify a lot of things
– user120323
Also has
!==
which means different in value and type, and===
equal in value and type. More information about operators you think at this link– Sam