473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

resetting rollover buttons

6 New Member
hello

i can change the button image using javascript but, i cant figure out
how to *re-set* the button to its original state when a different button
is pressed

i.e

button A = imageA.gif - when pressed the image changes to imageA2.gif

button B = imageB.gif - when pressed the image changes to imageB2.gif and
*re-sets* button A, back to imageA.gif from imageA2.gif

does that make sense?

any help please? script below...


thanks sophia


[HTML]<html>
<head>
<script language="JavaS cript">
<!--
if (document.image s) {
button1_down=ne w Image(); button1_down.sr c="imageA.gif ";
button1_up =new Image(); button1_up.src ="imageA2.gi f";

button2_down=ne w Image(); button2_down.sr c="imageB.gif ";
button2_up =new Image(); button2_up.src ="imageB2.gi f";
}

function pressButton(btN ame) {
if (document.image s)
eval('document. '+btName+'.src= '+btName+'_down .src');
}

function releaseButton(b tName) {
if (document.image s)
eval('document. '+btName+'.src= '+btName+'_up.s rc');
}
//-->
</script>
</head>
</html>

<html>
<body>
<a href="pages/page1.html" target="content "
onMouseDown="pr essButton('butt on1');return true;"
onMouseUp="rele aseButton('butt on1');return true;"
onMouseOut="rel easeButton('but ton1');return true;"
onClick="return true;">
<img name="button1" border="0" alt="page1" src="imageA.gif "></a>

<a href="pages/page2.html" target="content "
onMouseDown="pr essButton('butt on2');return true;"
onMouseUp="rele aseButton('butt on2');return true;"
onMouseOut="rel easeButton('but ton2');return true;"
onClick="return true;">
<img name="button2" border="0" alt="page2" src="imageB.gif "></a>
</body>
</html>[/HTML]
Dec 17 '07 #1
1 1111
acoder
16,027 Recognized Expert Moderator MVP
You don't need to use eval. Try this:
Expand|Select|Wrap|Line Numbers
  1. function pressButton(btName) {
  2.   if (document.images) {
  3.     document.images[btName].src=document.images[btName+'_down'].src;
  4.     if (btName == "button1")
  5.       document.images["button2"].src=document.images['button2_up'].src;
  6.     else
  7.       document.images["button1"].src=document.images['button1_up'].src;
  8.   }
  9. }
Dec 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1770
by: Max Biancofiore | last post by:
I am working on a new website. Please, can everybody go to www.intheloop.org.uk\sw5\index.html and tell me: 1) How long do the buttons take to download (please, also state connection speed)? 2) How does the image rollover for the buttons work? Especially concerning the preload.
4
1853
by: down_w/spam | last post by:
Hi all, I've done some research on this issue and am looking to you for further information on why IE still does a server look-up of a rollover image, even if the image has been preloaded and/or looked-up. I've tended to think that it is just a bug with IE but then i found a site that has rollovers that do not get looked up with IE. I thought that maybe they are using some special js script that fixed it. But no, it uses the same...
4
1957
by: Leythos | last post by:
I've got several sites that I used DreamWeaver MX to add RollOver buttons to the pages, it also adds some javascript that pre-loads the images and does the mouse_over and such. In FireFox 1.0.1 when I load the page and it pre-loads the images the status bar shows DONE. When I mouse over any item, it changes the image properly, but the status (lower left of browser) shows "Read www.somesite.com", it may also show "Waiting for...
4
1607
by: Matt | last post by:
i know more-or-less zero about javascript, but my client wants a rollover and he created this code, which doesn't work. All comments are appreciated. 1. the tag: <td align="center" width="66" nowrap="nowrap" background="/work/phc1.10/images/layout/main_nav_bg.gif"> <a href="http://localhost/work/phc1.10/index.php?page=homecare" onmouseover="imgSwap('','gnav_hc_on','gnav_hc_on')" onmouseout="imgSwap('','gnav_hc_off','gnav_hc_off')">
6
3197
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly highlighted and linked. The second button, has only a partial "hit area" at the top of the image, although if you click the link, you can see the link border is properly place around the image. The rest of the buttons have no rolloever state or link...
0
1140
by: Gepi Solo | last post by:
Hi, I'm a python newbie, coming from PHP & Perl. I'm developing client-server applications with a GUI. I'm trying to realize rollover buttons with images as background. I mean... I want to create a class which permit to create buttons with various shapes, (for instance something like this: O====O with a label and an image in the central part), that change their color/shapes when they have the focus on. I split the image of the shape into 3...
2
3445
by: Casimir | last post by:
I am looking into making pure CSS image rollovers. Do you have any clever (and robust) CSS rollover-tricks? Or links to such "in the wild"? I have figured out two methods for this, but have yet to do proper testing on browser support. Method I:
2
3048
by: eholz1 | last post by:
Hello CSS and StyleSheet members, I have decided to move away from Dreamweaver javascript rollover buttons, in favor of a CSS type rollover button. (hope that is ok). I plan to use PHP to include the page with the rollover buttons as a php include in a div for navigation buttons (left side of web page). I have cobbled together some code complements of http://sophie-g.net/jobs/css/e_buttons.htm.
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.