The window.location.href
property returns the URL of the current page, for example, if I open to put the command below in the page of that question, we will have the return of the URL of that page:
Script:
console.log(window.location.href);
Return:
http://pt.stackoverflow.com/questions/129417/windows-location-n%c3%a3o-funciona
Notice that the return has http://
to assign a new value to window.location.href
, we should also put the http
protocol, therefore it references a new URL, if it does not put it, it will understand that it is a page inside your site.
As your code, without http
up front would return something like this:
https://www.seusite.com/www.google.pt
Making the change your script looks like this:
function eliminaParagem (){
var confirma =confirm("Tem a certeza que quer eliminar a paragem");
if (confirma==true){
window.location.href="http://www.google.pt";
}
}
This way redirecting to another site.