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
Rollover button
Started by sexo, Aug 17 2006 07:41 AM
6 replies to this topic
#1
Posted 17 August 2006 - 07:41 AM
#2
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:)
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
Posted 17 August 2006 - 11:11 AM
sorry man seems i replied before seeing ur post 
well let me try it and see cause i dont know much about these code i just copied it from a site
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
Posted 17 August 2006 - 11:42 AM
man i searched other sites and the code is right but still not working
#5
Posted 17 August 2006 - 11:59 AM
Easy way to do it using css:
CSS:
The code you posted is...well....cant use them words on the forum lol. Using CSS is cleaner and easier.
<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
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.
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
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
