Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Add url to href on <a> tag but do not want to reload behavior

The following code opens the anchor tag on a new window However, I do not want to reload the parent page. And also I want to have the ability to Open in a new tab on mouse right click (image below)

enter image description here

If I use href = {'javascript:'} it prevents the parent page from reloading however, when clicked on "Open in a new Tab", it opens on a new tab but url becomes about:blank#blocked

const handleClick = () => {
      window.open(
        href,
        'newwindow',
        `width=${window.outerWidth * 0.5}, height=${
          window.outerHeight
        }, left = ${window.outerWidth * 0.25} `
      );
      return false;
  };

<a href = {href} onClick = {handleClick}> This is Url </a>

Desired result:

  • By default, open in a new window.
  • Prevent parent window from refreshing.
  • Have ability to open on new tab on right click.
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

To open the link in a new window or a new tab, you can use the target attribute in your anchor tag i.e. <a href="https://example.com" target="_blank">...</a>

about 4 years ago · Juan Pablo Isaza Report

0

You need target="_blank" for this.

<a href="www.google.com" target="_blank">Click</a>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!