Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[HTML HELP] Adding a link to a button

How do I add a link to this button?

<button type="submit" class="submit button-primary">Your Text Here</button>

Thanks.
<a href="#"><button type="submit" class="submit button-primary">Download Adobe Photoshop CC 2019</button></a>
Bro search online, it takes like 1 second

Got this from cuckoverflow

Code
<form action="https://google.com">
    <input type="submit" value="Go to Google" />
</form>
(Jul 23, 2020 11:23 PM)Xora Wrote:  Bro search online, it takes like 1 second

Got this from cuckoverflow

Code
<form action="https://google.com">
   <input type="submit" value="Go to Google" />
</form>

I check before I post here. This did not work for me.


(Jul 23, 2020 11:21 PM)Kant Atta Wrote:  <a href="#"><button type="submit" class="submit button-primary">Download Adobe Photoshop CC 2019</button></a>

Thank you mate <3
If you prefer using JavaScript:

Code
const btn = document.getElementById("myBtn");

btn.addEventListener('click', () => {
  window.open("http://whatever.com");
});

Here's a live example that should demonstrate it for you:
https://jsfiddle.net/9zsjybge/
[Image: vp6iypF.gif]
(Jul 25, 2020 08:55 AM)MavenGradle Wrote:  If you prefer using JavaScript

Code
const btn = document.getElementById("myBtn");

btn.addEventListener('click', () => {
window.open("http://whatever.com");
});

Thank you mate. Appreciate it.
(Jul 23, 2020 11:23 PM)Xora Wrote:  Bro search online, it takes like 1 second

Got this from cuckoverflow

Code
<form action="https://google.com">
   <input type="submit" value="Go to Google" />
</form>

You are misusing the functionality of a HTML Form to perform a simple redirect. The pimary functionality of a HTML Form is not to redirect but to submit data. Hence the input type "submit".

Using this, you would submit data to google.com which is potentially dangerous if you have any other form elements in your form.

I would recommend you to not use this method to perform a redirect if you value the privacy of your users and more importantly: this should only be used when submitting data to, for example, a backend API system.

Instead, one should opt for other solutions posted here, like for example the one posted below.
[Image: vp6iypF.gif]
Honestly I use to just create a regular link, and then style it myself.
Example:

HTML:
Code
<div class="button">
                <a href="example.html" class="btn">Example</a>
            </div>

CSS:

Code
.btn {
    font-family: 'Open Sans', sans-serif;
    border: 2px solid #374C6F;
    padding: 10px 40px 10px 40px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: white;
    background-color: #374C6F;
}

.button {
    padding: 50px 0 0 0;
}


There are rumors that this approach is best SEO wise too.
But again nothing that I personally have confirmed, I just find it more convenient to do my buttons like this.
(Jul 23, 2020 11:23 PM)Xora Wrote:  Bro search online, it takes like 1 second

Got this from cuckoverflow

Code
<form action="https://google.com">
   <input type="submit" value="Go to Google" />
</form>
My dog, why would you use a form to create a link? I bet you also use tables to structure your website.

Glad you got clapped, this was a retarded post for you to have made.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Account of the GodsDec 30, 2017 09:21 AM 6 225 Dec 30, 2017 09:21 AM
Last Post: Account of the Gods
by TomodachiAug 29, 2017 05:12 PM 9 248 Aug 29, 2017 05:12 PM
Last Post: Riggs
by Jeffr3yJan 14, 2017 02:27 PM 12 329 Jan 14, 2017 02:27 PM
Last Post: Nerdi