skip to Main Content

Usually, it is common and easy way to use href parameter to add a link on the web page. But I want to know other way so I wanna know about the method to add link not using href parameter.
If it is possible, please give me sample code.

I tried to make a link button not using href parameter. But I couldn’t find out that way.

2

Answers


  1. Using external javascript file

    <button id="linkButton">Go to Muuve</button>
    
    <script>
    document.getElementById('linkButton').addEventListener('click', function() {
        window.location.href = 'https://muuve-frontend.vercel.app/';
    });
    </script>
    

    Using inline js

    <button onclick="window.location.href='https://muuve-frontend.vercel.app/'">Go to Muuve</button>
    
    Login or Signup to reply.
  2. If you want to make a button that acts like a link, make a form and define the link as the form’s action:

    <form action="http://host/url/path" method="GET">
      <input type="submit" value="URL path">
    </form>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search