2

I have a <button> element inside a <form> that has onsubmit='return false' so if I try to link the button inside an <a> tag it won't be called. Right now if you click that button it will execute an animation, and since onsubmit returns false the page isn't reloaded, but I want that same button to open https://google.com i.e. after it has been clicked once, I've tried adding the attributes method=GET action=google.com to the form using JQuery once the button is clicked but it opens google on the first click, not in the second one. Any ideas?

<form class="box" id="box" onsubmit="return false">
  <button class="sign-button">Submit</button>
</form>
David
  • 3,166
  • 2
  • 30
  • 51
iDec
  • 707
  • 2
  • 8
  • 16

2 Answers2

1

A simple location.href="http://google.com"; should do the trick

micahblu
  • 4,924
  • 5
  • 27
  • 33
1

This will have to be done in JavaScript. In the example below I've used jQuery to make it simpler.

var checkedAlready = false;

$('.box button.sign-button').click(function () {
    if (!checkedAlready) {
        // Do animation...
        checkedAlready = true;
    } else {
        location.href = "http://google.com";
    }
});
David
  • 3,166
  • 2
  • 30
  • 51
krillgar
  • 12,596
  • 6
  • 50
  • 86