Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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

Solution 2:

You can do

<a href="dog.html" target="_blank" onclick="window.location.href ="dog.html";">Click</a>

Solution 3:

You can just use html without javascript for this. Try this code:

<a href="dog.html" target="_blank">Click</a>

Post a Comment for "How To Make A Link Open In New Tab As Well As Redirect In Current"