如何在调用window.open函数时在span标记中进行选择和属性设置



我有一个span标记,我想执行onclick函数,调用两个窗口。打开:

<span data-href="https://clkde.tradedoubler.com/click?p=300883&a=3040124&g=24628776" class="BUTTON_NZV" style="border-radius: 7px;
color: #FFFFFF;
font-family: Arial;
font-size: 31px;
font-weight: 600;
padding: 15px;
background-color: #1BC325;
text-decoration: none;
display: inline-block;
cursor: pointer;
text-align: center;
" onclick="window.open('#','_blank');window.open(this.data-href,'_self');">OK</span>

我想要的行为是在一个新的选项卡中打开实际的页面并专注于它,然后在不专注于它的情况下打开上一页中的数据href链接!你能帮我做那件事吗?

使用thisgetAttribute函数。

<span data-href="https://clkde.tradedoubler.com/click?p=300883&a=3040124&g=24628776" class="BUTTON_NZV" style="border-radius: 7px;
color: #FFFFFF;
font-family: Arial;
font-size: 31px;
font-weight: 600;
padding: 15px;
background-color: #1BC325;
text-decoration: none;
display: inline-block;
cursor: pointer;
text-align: center;
" onclick="window.open('#','_blank');window.open(this.getAttribute('data-href'),'_self');">OK</span>

最新更新