alert(location.href); // shows current URL
if (confirm("Go to codetogo?")) {
location.href = "https://codetogo.io/"; // redirect the browser to another URL
}
Thanks @politologu
There's a similar use case that allows you to get the current page URL
and for changing it, it's kinda the same variable which you need to change
Thanks!
alert(location.href); // shows current URL if (confirm("Go to codetogo?")) { location.href = "https://codetogo.io/"; // redirect the browser to another URL }