10

Essentially, all I want to do is open an external web page after the current page is loaded via java script.

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

How may I accomplish this?

6 Answers 6

24

you may 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> 
Sign up to request clarification or add additional context in comments.

Comments

3
<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> 

Hope it should be window.location. Check the code.

Comments

2

Technically you can:

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

… but you should perform an HTTP redirect instead as that is more reliable, faster and better food for search engines.

Comments

2

You can also use the "open" method to open the source file or url on a new window.

window.open("anyfile.*");

or

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

Comments

1

Hi please try this code for page loading time we will redirect whatever u configured the urls.

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

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

</html>

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.