Kris Ellison
Kris Ellison

Reputation: 47

In html how to link form submit to open in new tab and link relative URL?

I'm trying to link the submit button to open my URL in a new tab but at best I've managed to open an error window. Is the form action the correct way? Thanks

<div class="container">
      <h3>Contact Form</h3>
    ***<form action="_blank><a href="Home.html"></a>***
      <input type="submit" value="Submit"><br>
    </form>
    </div>

Upvotes: 0

Views: 915

Answers (3)

hackick7
hackick7

Reputation: 9

As the question was already answered by Eric, here I'm just reproducing the same HTML code in the question to be easier to understand

<div class="container">
  <h3>Contact Form</h3>
  <form target="_blank" action="Home.html">
    <input type="submit" value="Submit">
  </form>
</div>

Also, the question has been already answered here

Upvotes: 0

Eric Aig
Eric Aig

Reputation: 1084

You are not appropriately using the action attribute. You have to use _blank in the target attribute and then specify where to send the form-data when the form is submitted in the action attribute. Read more about HTML Form Attributes here.

Your code should look something like this:

<div class="container">
      <h3>Contact Form</h3>
      <form target="_blank" action="/receiveFormData.html"><a href="Home.html"></a>
      <input type="submit" value="Submit"><br>
    </form>
    </div>

Upvotes: 1

AREMU
AREMU

Reputation: 51

try this

<button title="button title" class="action primary tocart" onclick=" window.open('http://www.google.com', '_blank'); return false;">Google</button>

Upvotes: 0

Related Questions