I'm working on an exam project where students will click on an option which would open two tabs with different case studies and close the previous tab but I don't have experience with Javascript and I'm unsure how to approach the problem.
It's built on Wordpress and I've tried using various plugins but all of them have failed. I have managed to get links to open in new tab (no different to but not close the previous one or open two tabs with individual webpages.
We're using anchor tags currently in HTML and putting the javascript inline but I think we might need to tackle it differently, potentially through calling a javascript file.
We want to use Javascript as it'll allow us to add code to track users when they click on the link.
The page layout is very basic with one link on it (it has a pageview conversion tracking code to track the number of students taking the exam) so there's very little chance the script will conflict with anything else, this is why the previous tab should close automatically to avoid distraction
<a href="http://www.example.com" onclick="window.open('https://www.example.com');return false">Example</a>
It opens the webpage in a new tab but I'm unsure how to make it open two new tabs (different URLs) and close the previous tab.
(I noticed there are similar questions asked but none address closing the previous tab)