how to open link in a new tab? [duplicate]

2

Follow the code below that I'm having difficulty using target="_ blank" how could I solve this?

<div class="opt" onCLick="location.href='#';">Txt</div>

Thank you very much

    
asked by anonymous 10.11.2017 / 13:50

1 answer

5

If you really want to use a div to create a link, follow the example using Javascript :

<div class="opt" onCLick="window.open('https://www.google.com','_blank');">Txt</div>
  

Replace 'location.href' with 'window.open', so you can   set the 'target'.

If you want to make a simple link I recommend that you use the tag a :

<a href="https://www.google.com" target="_blank">Txt</a>
    
10.11.2017 / 14:03