在我的應用程式中,我創建了之前上傳的附件的小預覽。所以這里要打開它,需要右鍵單擊預覽并需要選擇在新選項卡中打開。
除了選擇之外,當用戶單擊影像在新選項卡上打開它時,我該如何更改?
<td>
<img alt="" width="100" height="100" class="ml-1" src="@Url.Action("RetrieveImage", new { id = item.Id } )"
</td>
我已經嘗試過這個,但是它在獲取影像的專案傳遞中顯示錯誤
<img alt="" width="100" height="100" class="ml-1" src="@Url.Action("RetrieveImage", new { id = item.Id } , new { @target="_blank"})"
uj5u.com熱心網友回復:
將影像作為嵌套標簽添加到a并為其指定target=_blank值,如下所示
<a href="@Url.Action("RetrieveImage", new { id = item.Id })" target="_blank">
<img width="220" height="250" border="0" align="center" src="@Url.Action("RetrieveImage", new { id = item.Id })"/>
</a>
uj5u.com熱心網友回復:
上面的答案是正確的,但我建議添加rel="noreferrer noopener". 由于僅使用target="_blank". 設定noopener noreferrer可防止網路釣魚攻擊。看看這篇文章:這里
<a href="your-url" target="_blank" rel="noreferrer noopener">
<img alt="" width="100" height="100" class="ml-1">
</a>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/360815.html
