PDA

View Full Version : need help with rollover button



Vile Demonic
06-02-2008, 10:34 AM
<img src="book.gif" name="bookgif" onMouseover="document.bookgif.scr=book2.gif"
onMouseout="document.bookgif.scr=book.gif">

i need that so it changes from one image to another and when you click it goes to the specified location. when i add in a href it vanishes, if i leave it without the href it doesnt link, but in both instances the image doesnt change. anyone know what im doing wrong?

Nile
06-02-2008, 12:13 PM
Does this work for you?:


<img src="book.gif" name="bookgif" onMouseover="this.scr=\"book2.gif\""
onMouseout="this.scr=\"book.gif\"" onClick=\"window.location='location here\"">

jscheuer1
06-02-2008, 01:18 PM
Does this work for you?:


<img src="book.gif" name="bookgif" onMouseover="this.scr=\"book2.gif\""
onMouseout="this.scr=\"book.gif\"" onClick=\"window.location='location here\"">


That won't work for anyone, especially the highlighted part, but the rest looks shaky too. This will work:


<a href="some.htm"><img border=0 src="book.gif"
onmouseover="this.src='book2.gif';"
onmouseout="this.src='book.gif';"></a>

There are many other ways. The above is about the simplest and provides non-javascript users at least with the link.

Vile Demonic
06-03-2008, 03:10 PM
<a href="some.htm"><img border=0 src="book.gif"
onmouseover="this.scr='book2.gif';"
onmouseout="this.scr='book.gif';"></a>

There are many other ways. The above is about the simplest and provides non-javascript users at least with the link.


oddly its still not changing even doing it this way

should i have a var or somethign that will load the images ready for roll over or somethign like that?

jscheuer1
06-03-2008, 06:12 PM
Preloading the rollover image(s) is a good idea. However, the main problem with this code is that I copied some of the typos from Nile's monstrosity, which he in turn had copied from you. Notably this.scr for what should have been this.src. Here is the corrected version (sorry for the error):


<a href="some.htm"><img border=0 src="book.gif"
onmouseover="this.src='book2.gif';"
onmouseout="this.src='book.gif';"></a>

If this the only rollover you have, a simple preload for it would be a script like this in the head of your page:


<script type="text/javascript">
var book_rollover=new Image();
book_rollover.src='book2.gif';
</script>

Vile Demonic
06-04-2008, 07:41 AM
ahh thank you and sorry i switch letters without noticing from time to time.

Vile Demonic
06-07-2008, 07:47 PM
does anyone know why this works in firefox and doesnt link in IE?

molendijk
06-08-2008, 10:07 AM
does anyone know why this works in firefox and doesnt link in IE?
Links well in IE6. Didn't try IE7.
---
Arie Molendijk

Nile
06-08-2008, 01:01 PM
That won't work for anyone, especially the highlighted part, but the rest looks shaky too. This will work:


<a href="some.htm"><img border=0 src="book.gif"
onmouseover="this.src='book2.gif';"
onmouseout="this.src='book.gif';"></a>

There are many other ways. The above is about the simplest and provides non-javascript users at least with the link.

Can someone tell me why ddadmin thanked that post?

jscheuer1
06-08-2008, 06:37 PM
Can someone tell me why ddadmin thanked that post?

The ddadmin works in mysterious ways.

Seriously though, perhaps he appreciates that I noted that your post was way off base.

To tell you the truth though, I haven't a clue.

Nile
06-08-2008, 07:42 PM
Haha, weird.

jscheuer1
06-08-2008, 09:41 PM
does anyone know why this works in firefox and doesnt link in IE?

I think it would work in IE. Do you have a demo page where it isn't working in IE? Which version of IE?

One thing I can say though is that, if you have an element with an id of:

book_rollover

And you are using the preload code I mentioned, and there are other references to book_rollover in your code, and/or you neglected to declare book_rollover as a variable (I did declare it in my example), that might cause a problem in IE.

johnwboyd
04-02-2009, 02:47 PM
I've tried several so-called pre-load scripts and they don't seem to accomplish anything. In my experience the only way to pre-load images is to put them in your code as invisible so that when the page is done loading the hover/ rollover image(s) are loaded already:
http://www.shoppingcartcash.com/rollover_submit_image_button.html#5