Is it possible to have input type="image" without src attribute?
maybe a little odd, but I'm stuck nevertheless:
I have an input type="image" which acts as a button within a software. I have to tweak the button for a template.
<input class="tweaked" src="" title="add to basket" alt="add to basket" type="image">
The problem:
- I cannot change the type, because the software seems to "bind" to input type="image"
- If I just omit the src attribute I get failed to load on IE and other browser开发者_运维百科
Question:
Is it possible to have an input type="image" without src attribute looking nice across browsers, that is without the "failed to load image"-icon? If so, how can it be done?
Thanks for help.
One option is to make the source of the image be a 1x1 clear pixel PNG. It's quick and dirty, and it will most likely work. You may even already have such a file that the site is downloading.
If, however, you don't want to add another HTTP request, perhaps you can set the source to be your image sprite, then in your CSS align the background so that the sprite is way, way off the image. This will get rid of the 1x1clear.png file, but it may degrade in a weird way in some cases.
Wacky idea that probably won't work, but you can try using a css (or jquery) selector to look for a missing src tag and set it to css display: none
or add a temp src tag pointing to a dummy image.
精彩评论