更新时间:2023-02-18 11:16:38
Your onclick
fires before the href so it will change before the page is opened, you need to make the function handle the window opening like so:
function changeLink() {
var link = document.getElementById("mylink");
window.open(
link.href,
'_blank'
);
link.innerHTML = "facebook";,
link.setAttribute('href', "http://facebook.com");
return false;
}