0

I am currently new in Web development. I am starting to develop my on website. For that I have a button and when I press it a new link will open. I want when I press the button link will open on the same tab and another link will open in new tab. some people told me I have to use JavaScript for solving this problem.I am working on Dreamweaver

4 Answers4

0

You would need Javascript in order to make it work on an ordinary button. An other option you could choose is to create a div, style it to look like a button and wrap it in a href. This way, you can specify the target: target="_blank".

Check @cgatian's answer for the Javascript solution.

Edwin Lambregts
  • 408
  • 6
  • 22
0

You can only specify one 'href' per tag and hence one link.

<a href="http://example.com/link1">Open Link 1 in current tab</a>

You can chose to open in a new tag by using the 'target' attribute on the tag.

<a href="http://example.com/link1" target="_blank">Open Link 1 in new tab</a>

You can only open two links at the same time (with one in a new tab) using JavaScript.

<a href="http://example.com/link1" onclick="
window.open('http://example.com/link1','_blank');
window.open('http://example.com/link2');
return false;">Open Link 1 in new tab and link 2 in this tab</a> 
(If JavaScript is disabled, will open link 1 in this tab)
thatitguy
  • 16
  • 3
0

You have to use DOM Document Object Model to access window properties and javascript. just give your button an id and access that id in a javascript function and use the concept of DOM

0

Why are you using button? Just use it as link/. For opening in new tab use

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

and for opening in same page use

<a href="http://www.w3schools.com/">Visit W3Schools!</a>
Saumyaraj
  • 1,220
  • 3
  • 15
  • 37