Button onclick windows.location.href




















The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. Question feed. Connect with us on Facebook and Twitter for the latest updates. Example Try this code ». Previous Page Next Page. All Rights Reserved. Share This:. Some will argue that links should always look like links and buttons should look like buttons. My goal is not to make you choose one side of the debate over another.

I just want you to be aware of this ongoing discussion. We could use the same styles as earlier, but we would have to add the cursor pointer and set the border to none, like this:. While this appears to be a working solution, there is a question if this is semantically correct. We are using the form tags but this does not function like a real form. The purpose of a form is to collect and submit user data. When you click on the button, something interesting happens with the URL.

The URL now has a question mark at the end of it. The reason for this change is because the form is using the GET method. You could switch to the POST method, but there might be cases where that is not ideal either.

But we can also use JavaScript to achieve the same result. The location. In this case, Window. If the user has decided to disable JavaScript in their browser, then clearly this solution would not work.

Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked Related Hot Network Questions.



0コメント

  • 1000 / 1000