@droidgoo: I’m not understanding what you are saying. What does the position attribute have to do with this? I’m strictly using display:none or display:inline to swap whether it’s the SVG or the fallback image that ‘exists’. I use display, rather than just opacity/visibility, so that the ‘hidden’ item doesn’t push any of the other content/affect the flow. I always only want ONE of the two items. I’m not using absolute positioning at all (…I avoid position attributes generally anyway, as they seem to cause me great grief in responsive pages).
@RobM: Ya, that’s what I thought right away, too (since I figured you can’t just drop script into the HTML)… but when I actually did, it produced loads of errors, for some reason (virtually every semi-colon, etc got marked as an error). Oddly enough, it seemed to work without putting it in script tags (even though I know that can’t be right). I tried a number of different methods to change the CSS/style… including using things like get GetElementByID (which didn’t seem to work, giving me an undefined error, even though I tagged the images with IDs)… GetElementsByClassName (which half-worked, but started giving me undefined errors if/when I used .style.display = “none”, rather than .display = “none”, which seemed to work ‘better’ (again, despite it being wrong).
At this point, everything is actually working, except that the still image (fallback for the SVG) is either not going away in the ‘SVG supported’ state, or it is not showing up in the ‘SVG not supported’ state… It’s always one works, but the other doesn’t, whatever the combo. It’s almost like I can only define the display state once (with the still image, at least), and if I try a second time, it gets ignored. The SVG element is actualy showing/hiding fine. At this point, it’s just the fallback image that is currently giving me grief.
My current code logic is:
-Detect SVG (as Boolean) and store in a variable.
-If variable is true, set the display of the SVG as inline.
-If variable is false, set the display of the fallback image as inline.
-In the body, have a div that has the SVG items, and in the same div, has the fallback image, with the assumption that only ONE of those will ‘exist’ (via the display attribute), and so the other will not only be invisible, but not take up any space. (I actually even took the precaution of also setting the height and width of the image to zero if SVG isn’t supported… just as an added precaution to ensure that even if it DID exist somehow, it would at least not push the other content/affect the flow).
Again, it all works, except for the fallback image not going away (or, with a variation of the code, not ever showing up).
I’m puzzled by the errors I’m getting when I try and do it verbetim/the way they are shown in examples… undefined errors.
I’ll post the current coding I’m using a little later today (…my work machine hasn’t been booted up yet, as I just got up recently… Long night!)