2 回答
TA贡献1842条经验 获得超13个赞
试试这个。如果它有效,它比使用javascript hrefs和链接中的包装按钮更好
您可以使用按钮而不是链接
window.addEventListener("load",function() {
document.querySelector("#imacro").addEventListener("click",function(e) {
e.preventDefault();
window.open(this.dataset.href)
})
})
.button {
display: block;
width: 100px;
height: 20px;
padding: 10px;
text-align: center;
border-radius: 5px;
border:1px solid black;
font-weight: bold;
text-decoration: none;
}
<a href="#" class="button" id="imacro"
data-href="imacros://run/?m=#current.js">
Run macro
</a>
TA贡献1834条经验 获得超8个赞
无法测试这个,但我会尝试:
<a
href="#"
onclick="javascript:window.open('imacros://run/?m=#current.js');return false;"
>
<button>Run macro</button>
</a>
添加回答
举报
