HTMl:
<div id="button">按钮</div>
JavaScript:
var button = document.getElementById("button");
button.addEventListener('click', function(){
let p = window.location.protocol;
let hostname = window.location.hostname;
let a = document.createElement("a");
a.setAttribute("href", `${p}//${hostname}:8081`);
a.setAttribute("target", "_blank");
a.click();
document.getElementsByTagName("body")[0].appendChild(a);
}, false)
网友评论