Javascript - Open a given URL in a new tab by clicking a button

前端 未结 13 474
一生所求
一生所求 2020-12-04 13:35

I would like to have a button that redirects to a given URL and opens in a new tab. How can this be done?

13条回答
  •  再見小時候
    2020-12-04 14:33

    Use this:

    
    

    Worked for me and it will open an actual new 'popup' window rather than a new full browser or tab. You can also add variables to it to stop it from showing specific browser traits as follows:

    onclick="window.open(this.href,'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no'); return false;"
    

提交回复
热议问题