簡體   English   中英

如何在新選項卡中打開鏈接以及在當前重定向

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

所以,我需要這樣做,如果用戶在mysite.com/cat上並點擊了某些內容,那么在mysite.com/cat標簽中,它們會重定向到mysite.com/dog並在新的鏈接中打開標簽。 我試過這個: <a href="dog.html" target="_self" onclick="window.open('cat.html');">Click</a>哪種工作,但它想...讓它變得奇怪

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

你可以做

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

你可以使用沒有javascript的html。 試試這段代碼:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM