以下是您的代码:
myId.onclick = function(){
open('https://www.example1.com');
location.href = ('https://www.example2.com',,'_blank');
}
myId.onclick = function(){
window.open('https://www.example1.com','_blank'); //just use window.open() for both the cases;
window.open('https://www.example2.com','_blank');
}
window.open('https://www.example1.com', '_blank');
。 - KBell<a href="#" id="myId">Open Two URLs</a>
var myId = document.getElementById("myId");
myId.onclick=function(){
window.open("https://www.google.com","_blank");
window.open("https://www.microsoft.com","_blank");
}
你应该允许浏览器的弹出窗口拦截器打开多个页面/标签才能使其正常工作。
window.open
}}打开两个URL:document.querySelector("#foo").onclick = function () {
window.open("https://www.example.com", "_blank");
window.open("https://www.example.com", "_blank");
};
<a id="foo">bar</a>
<a href="https://google.com" onclick="window.open('https://bing.com')" target="_blank">HTML + JavaScript HTML:</a>
,它可以工作? - evolutionxbox