摆脱执行 imacros 脚本时打开的第二页

我如何摆脱使用此href执行imacros脚本时打开的第二个页面

http://img3.mukewang.com/62fdef930001577a08280373.jpg

第一个选项卡是一个简单的 html 页面,其中包含以下标记:


<a target="blank" 

  href="javascript:window.open('imacros://run/?m=#current.js');">

    <button>Run macro</button>

</a>

单击此链接时,将打开第二个选项卡,其中包含图像中的内容以及我要删除的选项卡。第三页包含我要执行的内容。


注意:我想让第一页保持打开状态。


湖上湖
浏览 141回答 2
2回答

红颜莎娜

试试这个。如果它有效,它比使用javascript hrefs和链接中的包装按钮更好您可以使用按钮而不是链接window.addEventListener("load",function() {&nbsp; document.querySelector("#imacro").addEventListener("click",function(e) {&nbsp; &nbsp; e.preventDefault();&nbsp; &nbsp; window.open(this.dataset.href)&nbsp; })}).button {&nbsp; &nbsp; display: block;&nbsp; &nbsp; width: 100px;&nbsp; &nbsp; height: 20px;&nbsp; &nbsp; padding: 10px;&nbsp; &nbsp; text-align: center;&nbsp; &nbsp; border-radius: 5px;&nbsp; &nbsp; border:1px solid black;&nbsp; &nbsp; font-weight: bold;&nbsp; &nbsp; text-decoration: none;}<a href="#" class="button" id="imacro"&nbsp; data-href="imacros://run/?m=#current.js">&nbsp; &nbsp;Run macro</a>

MMMHUHU

无法测试这个,但我会尝试:&nbsp; &nbsp; <a&nbsp; &nbsp; &nbsp; href="#"&nbsp; &nbsp; &nbsp; onclick="javascript:window.open('imacros://run/?m=#current.js');return false;"&nbsp; &nbsp; >&nbsp; &nbsp; &nbsp; <button>Run macro</button>&nbsp; &nbsp; </a>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript