0

I have this piece of code:

<button name='link' onclick="window.location.href = 'Text.html';"  
style="cursor:pointer"  class='Text' value='Text.html' title='Text'>Text</button>

On click it will take you to one of my sub-sites. I wanted it to open the link in a new tab so I tried putting target='_blank' in the button tag, but it didn`t work. If possible I would prefer to use HTML.

Thanks

Banana.html
  • 35
  • 14

3 Answers3

0

Edit: While the original answer works, it isn't in line with the W3C HTML5 specs. An alternative would be to edit the JavaScript in the onclick attribute to open the link in a new tab.

<button
  onclick="window.open('Text.html', '_blank')"
  name="link"
  style="cursor: pointer"
  class="Text"
  value="Text.html"
  title="Text"
>
  Text
</button>

You could wrap an <a> tag around the button instead.

<a href="Text.html" target="_blank">
  <button
    name="link"
    style="cursor: pointer"
    class="Text"
    value="Text.html"
    title="Text"
  >
    Text
  </button>
</a>
Phishy
  • 79
  • 5
0

What about using form

<form action="//example.com/Text.html" target="_blank">
    <button type="submit">Text</button>
</form>

This can take to different site or any of your sub-site.

0

Replace button tag with a

<a href="Text.html" title="Text" target="_blank">Text</a>
Lekh Raj
  • 80
  • 1
  • 4