Jump to content


Rollover button


6 replies to this topic

#1 sexo

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 17 August 2006 - 07:41 AM

hey guys


well i am trying to create a rollover button , i searched for the code and i found this

<A
HREF="http://www.liusn.com/phpproxy/index.php"
onMouseOver = "rollover('home')"
onMouseOut = "rollout('home')"
><IMG
SRC="http://imageshacked.com/uploads/08c30a625a.jpg"
NAME="home"
ALT="Enter PHP Web Proxy" BORDER=0
HEIGHT=99 WIDTH=162
></A>
<script TYPE="text/javascript">
<!--
setrollover("http://imageshacked.com/uploads/6ad4870f2e.jpg");
//-->
</SCRIPT>

but its aint working why?
the button actually appear and the link is fine but there is no rollover

#2 Erik Bernskiold

    Jedi In Training

  • Members
  • PipPip
  • 422 posts
  • Gender:Male
  • Location:Gothenburg, Sweden
  • Interests:I love to do booth Web Design and Photography. Nothing beats a nice day out in the nature with the camera gear, getting loads of nice photos. I have been playing the flute for 6 years now and I love it, and I am playing the pipe organ as well. I also like to teach other people the in and outs of software such as the CS3 suite from Adobe.

Posted 17 August 2006 - 11:05 AM

Is it just me that find this code a bit odd?

I am no js expert but this code bit doesn't feel right. Please correct me if I am wrong, but it seems weird to add a rollover overall to the <a> tag, shouldn't that be on the <img /> tag? There might be other probs in this code or it might not work at all, but thats what caught my eye:)

#3 sexo

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 17 August 2006 - 11:11 AM

sorry man seems i replied before seeing ur post :D

well let me try it and see cause i dont know much about these code i just copied it from a site

Edited by sexo, 17 August 2006 - 11:12 AM.


#4 sexo

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 17 August 2006 - 11:42 AM

man i searched other sites and the code is right but still not working

#5 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 17 August 2006 - 11:59 AM

Easy way to do it using css:

<div id="nav">
	<a href="#">link text</a>
</div>

CSS:

#nav a, a:visited, a:active
{
	background: #fff url( image.ext ) repeat-x left;
	/* more styling */
}

#nav a:hover
{
	background: #fff url( image_on_hover.ext ) repeat-x left;
}

The code you posted is...well....cant use them words on the forum lol. Using CSS is cleaner and easier.

Edited by .Matt, 17 August 2006 - 12:02 PM.


#6 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 17 August 2006 - 12:28 PM

Yes, Matt's got the perfect code there, lol. Other than the fact that you have to assign a new id and style for every image you want a rollover on.
But, with JavaScript you need to do that anyways.

Anyways, just for reference, the code you posted is terrible. It's main problem is that it's trying to utilize a function that does not exist. IT should have 'rollover()' and 'rollout()' as defined functions in the head of the page. The function simply changes the source (document.image_id.src) to that of something else. So, the hyperlink would also need the id of the image it is to change, otherwise it won't do squat.
And Erik, you could use it on the img tag, it would be easier since you wouldn't need to assign an id, but problem is, alot of browsers don't support that, and it's not proper use of the DOM. ;)

#7 sexo

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 17 August 2006 - 06:21 PM

thx guys for the help





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users