如何在新标签中打开链接以及在当前重定向 [英] How to make a link open in new tab as well as redirect in current
本文介绍了如何在新标签中打开链接以及在当前重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< a href =dog.htmltarget =_ selfonclick =window.open('cat.html');>点击< / a>
哪种类型的工作,但它会喜欢...让这一切都很奇怪解决方案
< a href =#target = _selfonclick =RedirectUrl()>点击< / a> <脚本>函数RedirectUrl(){window.location.href =yourUrl; }< script>
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
解决方案
<a href="#" target="_self" onclick="RedirectUrl()">Click</a>
<script>
function RedirectUrl(){
window.location.href ="yourUrl";
}
<script>
这篇关于如何在新标签中打开链接以及在当前重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文