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>
添加回答
舉報