Redirect a web page

1

I tried to redirect my server-mounted page to

  

192.168.xxx.xxx

a

  

192.168.xxx.xxx:8080/web/

using

window.location
window.location.href
document.location
document.location.href
windows.location.replace()

they all give me the same result

  

192.168.xxx.xxx/192.168.xxx.xxx:8080/web/

Any ideas or ways to do it?

html

<html>
<head>
        <meta charset="UTF-8">
        <title></title>
<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://192.168.XXX.XXX:8080/web/'>
</head>
<body>
<!--
<script>
 function red(){
      window.location.replace("http://192.168.XXX.XXX:8080/web/");
}

red();

</script>
-->
</body>
</html>
    
asked by user75463 19.03.2018 в 06:02
source

1 answer

1

window.location.replace(...) is better than using window.location.href , because replace () does not keep the source page in the history of the session, which means that the user will not get stuck in an endless back-end.

  

If you want to simulate a link, use location.href

     

If you want to simulate an HTTP redirect, use location.replace

For example:

// comportamiento similar HTTP redirect
window.location.replace("http://stackoverflow.com");

// comportamiento similar al presionar en un link
window.location.href = "http://stackoverflow.com";

In your case, you can use both but I recommend the window.location.href since it will be an automatic redirect. You should also put the http: // in front, so that it is interpreted as such.

Source

    
answered by 19.03.2018 в 10:07