HTML button opening link in new tab

前端 未结 8 1258
挽巷
挽巷 2020-12-05 17:32

So this is the simple code for the button to open a certain link

                
相关标签:
8条回答
  • 2020-12-05 17:58

    You can use the following.

    window.open(
      'https://google.com',
      '_blank' // <- This is what makes it open in a new window.
    );
    

    in HTML

     <button class="btn btn-success" onclick=" window.open('http://google.com','_blank')"> Google</button>
    

    plunkr

    0 讨论(0)
  • 2020-12-05 17:59

    Try this code.

    <input type="button" value="Open Window"
    onclick="window.open('http://www.google.com')">
    
    0 讨论(0)
提交回复
热议问题