Open page automatically with javascript

Essentially, all I want to do is open an external webpage after loading the current page through a java script.

open my page -> javascript tells browser to open external page -> external page being loaded into the broser

How can i do this?

+5
source share
6 answers

you can use this

<html>
    <head>
    <script type="text/javascript">
    function load()
    {
    window.location.href = "http://externalpage.com";

    }
    </script>
    </head>

    <body onload="load()">
    <h1>Hello World!</h1>
    </body>
    </html> 
+13
source

Technically, you can:

location.href = "http://example.net/";

... but instead, you should redirect the HTTP redirect as it is more reliable, faster, and better food for search engines.

+2
source
<html>
<head>
<script type="text/javascript">
    function load()
    {
        window.location.href = "http://externalpage.com";
    }
</script>
</head>

<body onload="load()">
   <h1>Hello World!</h1>
</body>
</html> 

, window.location. .

+2
<body>
<script>
document.body.innerHTML += '<a href="https://www.google.com/" style="display: none;" id="link">Link</a>';
document.getElementById("link").click();
</script>
<body>
+1

"", URL- .

window.open("anyfile.*");

window.open("http://anylocation.com");
0

Hi, please try this code for page load time, we will redirect everything that configured the urls.

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
   window.open('https://google.com');
}
</script>
</head>

<body onload="myFunction()">
</body>

</html>
Run codeHide result
-1
source

All Articles