When I click on the link it will scroll up to the page rather than fire actual onClick event and open another page...
My ReactJs Code:
<a
href={HELP_URL}
className={s.supportLink}
target="_blank"
rel="noopener noreferrer"
onClick={() => handleFAQClick({ onPageStepChange, location })}
>
FAQs
</a>
It should open a new page in a new tab as per mentioned link in "href".
Add event.preventDefault()
to your javascript code.
Try something like this:
function handleFAQClick() { event.preventDefault(); //<-- If you remove this, your link will try to send you to another page by default. //Your code... //Eg alert: alert("It works!"); }
<a href="" className="" target="_blank" rel="noopener noreferrer" onClick="handleFAQClick()"> FAQs </a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.