PDA

View Full Version : looking for simpler rollover script


shellyblake
06-02-2002, 11:51 AM
is the only way to create a rollover script is to put all the code in the header? isn't there an easier way? isn't there a way to put all the rollover info in the actual line - for example...

instead of image.src referring to the script in the header -like this:

<a href="filename.html" onmouseover="image1.src='images/button.gif';"
onmouseout="image1.src='images/button2.gif';">

couldn't you just leave out the image.src stuff? like this:

<a href="filename.html"
onmouseover="images/button.gif';"
onmouseout="images/button2.gif';">

Now, I know this doesn't work - but that's my question - isn't there a way to make something like this work? so we don't have to have all the code at the top. or at least so the code at the top doesn't have to contain all the info needed to make it work - maybe it just contains code that tells it "what" to do, but not "where" to go. am i making sense?
the reason I'd like to find something is because if i decide to add a rollover button late in the game - i don't like having to go back & change it everywhere to make it work. i'm hoping to find something similar to how the style sheets work (hover). I know FP has a way of doing it (kinda) but it's some kind of applescript & I hate it because it actually creates loadtime. I'm guessing what I'm asking for might as well?
i'm guessing this is a pipe-dream but I'm hoping someone can help me!
thanks.

Jon Hanlon
06-02-2002, 07:01 PM
This is what Microsoft's Behaviors (http://msdn.microsoft.com/workshop/author/behaviors/overview.asp) were designed to do. Microsoft wanted a way of divorcing content from script, but unfortunately behaviors can be rather complicated until you get used to them.
Behaviors use the class attribute or an in-line style to attach a behavior to an element, and naturally enough only work on IE5+.

tbonem91
06-17-2002, 12:26 PM
<img src="/images/harley.jpg" onmouseover="this.src='/images/honda.jpg'" onmouseout="this.src='/images/harley.jpg'">

There you go