Reputation: 132
as soon as you click on the picture, the picture will be swapped and a new window will open automatically on https://stackoverflow.com/. Any ideas/support what i have missed that this combination would work? Currently the picture is swapping, unfortunately the new window doesn't open.
document.getElementById("img").onclick = function() {
if(this.src == "https://www.w3schools.com/html/img_girl.jpg"){
this.src = "https://www.w3schools.com/html/pic_trulli.jpg";
} else {
this.src = "https://www.w3schools.com/html/img_girl.jpg";
}
};
<a href="##"onClick="window.open('https://stackoverflow.com/', '_blank','width=900,height=880, toolbar=no,location=no,directories=no,statu s=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no'), BoldText(this);"><img id="img" src="https://www.w3schools.com/html/img_girl.jpg" height="22" width="22" alt="Twitter"></a>
Upvotes: 0
Views: 486
Reputation: 74
The new window isn't opening because it's being blocked be either the browser or an ad-block extension! Try disabling your ad-block extension if you have any and allowing pop-ups in your browser settings for your page!
Upvotes: 0
Reputation: 1229
I have no problem with the img swapping and opening up in new window.
Your _blank
should cover the new window.
From jsfiddle I have it working: https://jsfiddle.net/xg1w7b6o/
What browser are you using? Maybe its browser specific that the window is not opening.
Upvotes: 1