OK so I know this question has been asked separetly but I'm trying to use javascript to replace a broken image with another image with DIFFERENT dimensions by changing th src attribute. Here's a part of my code:
MARKUP:
...
<img id="error-img" class="img-header" onerror="imgError(this);" alt="Header" src="images/header.png">
...
STYLES:
...
.img-header { width: 54px; height: 64px; }
...
JAVASCRIPT:
...
function imgError(image) {
image.onerror = "";
image.src = "/images/broken.png";
return true;
}
...
So what I need is to include a piece of code in this function so that when the image gets replaced the new image has it's dimensions set correctly but not 54x64px.
EDIT:
Thank you for the answers guys but I've forgot to mention the size of the broken.png image:
Width: 276px Height: 45px.