hey so i'm trying to use onerror with img tag which will check if website is up or not. According to my research i have done onerror can be used to get status for website. So what i'm trying to accomplish is if website has an 404 it will return an image which red color however if website is up and running then it will show an green image. So i was able to come up with a code that does the trick but issue is i want to combine the code so it will only show one image at a time except two below is sample of my code any help will be apprecaited.
<img src="badlink" onerror="this.onerror=null;this.src='https://upload.wikimedia.org/wikipedia/commons/thumb/2/25/Red.svg/120px-Red.svg.png'" />
<img src="https://www.google.com" onerror="this.onerror=null;this.src='http://greensportsalliance.org/images/darkGreenSquare.gif'" />