why is the <img> alt attribute not always properly displayed
        Posted  
        
            by Piero
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Piero
        
        
        
        Published on 2010-05-28T12:33:00Z
        Indexed on 
            2010/05/28
            12:41 UTC
        
        
        Read the original article
        Hit count: 447
        
So I have this php script that output an html table with data about some files (like filename, filesize, etc...)
I have this javascript function that displays the picture when you hover a tag belonging to the class "preview". For example, if a filename is: somePic.jpg, when you hover somePic.jpg in the table, the picture will appear next to your mouse.
Now not all these files are pictures, some are .mp3, so of course when you hover them, the javascript cannot display the picture. To deal with this case, I added in the tag (generated by the javascript function), an alt attribute: alt='Preview not available for this type of content.'
And here is my problem, sometimes it works, but sometimes it doesn't! Sometimes you start hovering .mp3 links, and the alt attribute is displayed, then you hover a picture, the picture is displayed, then you hover an .mp3 again, and the alt isn't displayed anymore, but the "broken image" image (the little red cross) is displayed instead...
Sure I could parse the filenames and detect when it's an mp3 and then deal with the case, but I thought the alt attribute was suppose to achieve this... but it's buggy...
Any idea? Does anyone already faced this problem?
© Stack Overflow or respective owner