open page automatically using javascript

前端 未结 6 1610
星月不相逢
星月不相逢 2020-12-19 04:38

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 o

相关标签:
6条回答
  • 2020-12-19 04:59
    <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.

    0 讨论(0)
  • 2020-12-19 05:02
    <body>
    <script>
    document.body.innerHTML += '<a href="https://www.google.com/" style="display: none;" id="link">Link</a>';
    document.getElementById("link").click();
    </script>
    <body>
    
    0 讨论(0)
  • 2020-12-19 05:04

    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> 
    
    0 讨论(0)
  • 2020-12-19 05:11

    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>

    0 讨论(0)
  • 2020-12-19 05:12

    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.

    0 讨论(0)
  • 2020-12-19 05:12

    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");
    
    0 讨论(0)
提交回复
热议问题