Jelly Jelly - 6 months ago 15
HTML Question

How to make a link open in new tab as well as redirect in current

So, I need to make it so if the user is on mysite.com/cat and they click something, then in the mysite.com/cat tab, they are redirected to mysite.com/dog AND a link is opened in a new tab. I tried this:

<a href="dog.html" target="_self" onclick="window.open('cat.html');">Click</a>
which kind of worked, but it would like... make it all weird

Answer

   
<a href="#" target="_self" onclick="RedirectUrl()">Click</a> 
<script>
    
    function RedirectUrl(){    
       window.location.href ="yourUrl";
    }
    <script>

Comments