html - 单击指向超链接的按钮时,如何避免原始页面转到不同的页面?
问题描述
注意:我希望我的链接在新选项卡中打开,但将其保留在原始选项卡所在的位置。然而,原来的标签会导致不同的地方?
.btn {
background-color: transparent;
border-radius: 28px;
border: 1px solid #0762C8;
display: inline-block;
cursor: pointer;
color: #0762C8;
font-family: Tahoma;
font-size: 14px;
padding: 4px 13px;
text-decoration: none;
position: absolute;
margin-top: -10%;
}
.btn:hover {
background-color: #0762C8;
border-color: #0762C8;
}
.btn:active {
position: relative;
top: 1px;
}
.flex-container {
display: flex;
justify-content: center;
}
<div class="col-12 col-md-6 col-lg-4 py-3 text-center border"><a
href="http://www.example.net/" target="_blank"
><img class="img-fluid" font-family:lucida="" sans=""
src="/images/contentimages/images/Giveaways.png" /></a>
<p class="my-3" style="font-size:18px;"> </p>
<div class="flex-container"><a class="btn btn-info btn-sm edatalayer order-1" onclick=" window.open('http://www.example.net/','_blank')"
data-list="product-listing-page" data-position="1" data-purl="custom-business-forms"
>Giveaways <i class="far fa-chevron-right pl-1"></i></a></div>
</div>
解决方案
您可以使用onclick
:
<a href="https://example.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
推荐阅读
- .htaccess - htaccess 使用另一个环境变量设置环境变量
- javascript - 使用扩展运算符或 Object.assign 将子节点的所有节点复制到父节点,避免覆盖相同的属性
- java - 矩阵相乘时接收错误
- java - Thymeleaf - 如何创建进度条?
- sql - Delta Lake MERGE / UPDATE rewriting data even when condition is not met
- python - Why the loss still repeat?
- sql - Oracle 返回计数的最高值
- spring - 我如何弄清楚注册有什么问题?
- powershell - 如何在 powershell 中重置 Windows.Form 的内容?
- r - 为 CentOS Linux 寻找 R 4.0.3 的编译版本