0

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>

1
  • Get rid of BoldText and it does work. I would suggest putting it into a JavaScript expression instead of inline. Commented Oct 7, 2019 at 19:41

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, so much i rechecked and now it works, on this time it did not work. maybe i had an issue with my cache.. sorry for that and thank you for your help
No problem, glad I could help
0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.