I want to open a new tab instead of a popup window

后端 未结 3 1884
一生所求
一生所求 2020-12-19 06:14

I am trying to open a new tab. But Window.open() is opening up popup window.

I want to open hello.php file in a new tab. But it is opening

相关标签:
3条回答
  • 2020-12-19 06:37

    assign the url to open to a tag's href attribute, with target="_blank", then trigger link click when you want. Example:

    <a id="myLink" href="hello.php?username=<?php echo $username; ?>" target="_blank">
    

    Then, call a js function to trigger link click

    document.getElementById('myLink').click();
    
    0 讨论(0)
  • 2020-12-19 06:45

    In case it could be a javascript issue about override functions, do that:

    <script>
    (function(window, undefined){
        var win = window.open('your_url', '_blank');
        win.focus();
    })(window);
    </script>
    

    That should make you can't use functions from other javascript code out of your function(window, undefined) wrapper-

    0 讨论(0)
  • 2020-12-19 06:48

    You can do it by window.open(url, '_blank');

    0 讨论(0)
提交回复
热议问题