Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I go to an external link when I click on a button in next js

<button type="button" className = {styles.googleButton}>
     <img className = {styles.image} src = "assets/pictures/google.jpg"></img>
     <p className = {styles.buttonText}> Go To Google</p>
     <img src = "assets\icons\external-link.svg"></img>
</button>

when i click on this button how do i go to google.com on A DIFFERENT TAB?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Add an ‘a’ tag and set its target value to ‘_blank’. Also add "rel=’noreferrer’".

Here is an example. It’s working for me in my Nextjs project:

  <a href='https://www.google.com' target='_blank' rel='noreferrer'>
    <button type='button'>
      <img src='assets/pictures/google.jpg'></img>
      <p> Go To Google</p>
      <img></img>
    </button>
  </a>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading