I would like to get a url that is just after red=
and redirect to it, if it is blank do not redirect. I've used window.location.replace("")
just to test the code.
Example where I want to get: red=http://www.google.com/
The code has the function of replacing content within an element, and redirect the page in a few seconds.
window.onload = function substituir() {
var url = new URL(window.location);
var sub = url.searchParams.get("sub");
var red = url.searchParams.get("red");
setTimeout(redirecionar, 5000);
if(sub == 1) {
document.getElementById("subst").innerHTML = "<p>Alguma coisa</p>"
}
function redirecionar() {
if(red == 1) {
window.location.replace("https://www.google.com");
}
}
}