I’ve got a HTML / CSS problem that has me stumped and my online sources are failing me. All my experiments have come to naught.
I have a web page that contains an element like:
<img id=“myImgID” src=“SomeGraphic.gif”>
I need to modify the final browser-side result so the browser interprets that tag to display a different graphic, say “OtherGraphic.gif”. Easy, right? But …
The page is dynamically generated by code we don’t control and we have NO ability to modify the HTML emitted by the server. None.
We also do NOT have the ability to insert any script into the page, either directly inline, or by modifying a server-side file referenced by something like:
<script type=“text/javascript” src=“SomeScript.js”></script>
And no, we can’t just replace the contents of the one graphic with the other.
What we DO have is that the HTML references a server-side CSS file like this:
<link rel=“STYLESHEET” type=“text/css” href=“MyStyleSheet.css”>
and we CAN modify the MyStyleSheet.css file.
So: Is it possible to insert css elements into the css file which will have the effect of changing the value of the img tag’s src attribute? We can rely on the ID of the desired img tag being both static and unique.
Is there a way to sneak script into the css? It’d need to be both the script call and the source code, not just a call to script that would have to be loaded elsewhere.
The target browser is IE6, plus ideally all the other modern ones.