Forum Moderators: not2easy

Message Too Old, No Replies

onload: in an CSS img block?

onload: in an CSS img block?

         

bossatres

4:29 am on Jun 21, 2005 (gmt 0)

10+ Year Member



Hello, thanks for reading. Is this legal, or no? What am I doing wrong?

<style type="text/css">
img.info {
onload:document.getElementById('h44').src='http://www.x.com/ms.php?u=foobar;
}
</style>

<img src="location" id="h44" class="info">

I want to be able to have the onload event handler do different things depending on the class that I assign.

Can event handlers be defined in css?

Can I include the id tag in the CSS?

Can any possible attribute that a particular tag can have be defined in a CSS script?

Moby_Dim

7:11 am on Jun 21, 2005 (gmt 0)

10+ Year Member



No, you can not write javascripts using css classes. Only ie specifyc "expression" resembles this. Setting css properties via javascript is the right way.