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)
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:
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>
You need target="_blank" for this.
<a href="www.google.com" target="_blank">Click</a>