How can I get rid of this second page that opens when using this href to execute an imacros script
the first tab is a simple html page that contains this tag:
<a target="blank"
href="javascript:window.open('imacros://run/?m=#current.js');">
<button>Run macro</button>
</a>
when clicking this link a second tab opens containing what in the image and that the one I want to get rid of. the third page contains what I want to execute.
note: I want to keep the first page open.
Try this. If it works, it is better practice than using javascript hrefs and wrapping buttons in links
You can use a button instead of a link
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>