473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

sorry ... total noob rollover debug

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' )">
<img name="gnav_hc_off"
src="/work/phc1.10/images/layout/gnav/gnav_hc_off.gif" border="0"
alt="Homecare" width="66" height="14" /></a>
</td>
2. the function:

function imgSwap(layer,imgName,imgObj) {
var layer;
var imgName;
var imgObj;
glayer = layer;
gimgName = imgName;
gimgObj = imgObj;
if(document.images) {
//NN 4.x DOM
if(document.layers && layer != "") {
eval('document.' + layer + '.document.images["' + imgName + '"].src =
' + imgObj + '.src');
}
//NN6 Gecko subroutine
else if((objClient.application == "nn") && (objClient.version >= 5)) {
imgSwapTimeOut();
}
else {
document.images[imgName].src = eval(imgObj + ".src");
}
}
}
//NN Gecko subroutine
function imgSwapTimeOut() {
document.images[gimgName].src = eval(gimgObj + ".src");
}
Jul 23 '05 #1
4 1568
the "bug" is that the swap doesn't seem to occur. I have the javascript
console open and no error appears there. My dev box is Lx/firefox, but I
looked at it in IE as well and it's no good there either.

Thanks again.
Jul 23 '05 #2
alu

"Matt" <ma************@spamlessverizon.net> wrote
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' )">
<img name="gnav_hc_off"
src="/work/phc1.10/images/layout/gnav/gnav_hc_off.gif" border="0"
alt="Homecare" width="66" height="14" /></a>
</td>
2. the function:

function imgSwap(layer,imgName,imgObj) {
var layer;
var imgName;
var imgObj;
glayer = layer;
gimgName = imgName;
gimgObj = imgObj;
if(document.images) {
//NN 4.x DOM
if(document.layers && layer != "") {
eval('document.' + layer + '.document.images["' + imgName + '"].src =
' + imgObj + '.src');
}
//NN6 Gecko subroutine
else if((objClient.application == "nn") && (objClient.version >= 5)) {
imgSwapTimeOut();
}
else {
document.images[imgName].src = eval(imgObj + ".src");
}
}
}
//NN Gecko subroutine
function imgSwapTimeOut() {
document.images[gimgName].src = eval(gimgObj + ".src");
}


There are probably a million better written / less complex rollover scripts
out there, do you really need to use this one? If so, for starters, he
hasn't
set any image src's.
Secondly, the mouseover imgSwap('','gnav_hc_on','gnav_hc_on')"
should likely be imgSwap('','gnav_hc_off','gnav_hc_on')" since there is no
image named 'gnav_hc_on'.
If this is for a single rollover, (or perhaps in any case) junk the script,
not worth the trouble. Not to mention the <td> tag.
-alu
Jul 23 '05 #3
ASM
Matt wrote:
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.
Your client use DW ? and its MacroMerdum ? and that doesn't work ?
Tremendous !

Try to tell him there is better way using css to get a rollover.
i.e :
http://perso.wanadoo.fr/stephane.mor..._etats_css.htm
that doesn't need pre-loading of images and is much cheaper

there are very simple ways to set a rollover

the easiest but the worst :

<a href="somePage.htm" target="_blank"
onmouseover="ir=document.images('foo'); ir.src="img_over.gif;"
onmouseout="ir.src="img_out.gif">
<img name="foo" src="img_out.gif" border=0></a>
better :

<script type="text/javascript"><!-- // script to put in header

// sometimes the following pre-loads images (NC4, IE4 to FF1.0.4, IE6)
if(document.images) {
But_01 = new Image(); But_01.src = 'buttons/I_01.gif'; // normal
But_01o = new Image(); But_01o.src = 'buttons/O_01.gif'; // over

But_02 = new Image(); But_02.src = 'buttons/I_01.gif'; // normal
But_02o = new Image(); But_02o.src = 'buttons/O_01.gif'; // over

// and so on for each button
}

function di(name,id) { if(document.images)
eval(document.images(name).src = id+'.src'); }

// --></script>
</head>
<body>
<a href="somePage.htm"
onmouseover="di('Ig_01','But_01o');
onmouseover="di('Ig_01','But_01');>
<img name="Ig_01" src="buttons/I_01.gif" border=0></a>
<a href="someOtherPage.htm"
onmouseover="di('Ig_02','But_02o');
onmouseover="di('Ig_02','But_02');>
<img name="Ig_02" src="buttons/I_02.gif" border=0></a>
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' )">
<img name="gnav_hc_off"
src="/work/phc1.10/images/layout/gnav/gnav_hc_off.gif" border="0"
alt="Homecare" width="66" height="14" /></a>
</td>
2. the function:


ask to DreamWeaver

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #4
I junked the old script and am getting some functionality with this:

if (document.images) {
gnav_ho_up = new Image();
gnav_ho_up.src = "/work/phc1.10/images/layout/gnav/gnav_ho_off.gif" ;
gnav_ho_down = new Image() ;
gnav_ho_down.src = "/work/phc1.10/images/layout/gnav/gnav_ho_on.gif" ;
}

function buttondown( buttonname )
{
if (document.images) {
document[ buttonname ].src = eval( buttonname + "_down.src" );
}
}
function buttonup ( buttonname )
{
if (document.images) {
document[ buttonname ].src = eval( buttonname + "_up.src" );
}
}
tag:
<a href="http://localhost/work/phc1.10/index.php?page=phchome"
onmouseover="buttondown('gnav_ho')"
onmouseout="buttonup('gnav_ho')">

<img name="gnav_ho"
src="/work/phc1.10/images/layout/gnav/gnav_ho_off.gif" border="0"
alt="Home" width="100" height="14" /></a>

problem: it's saying that image can't be found. the reference in the
<img ...
tag works -- that image appears. but when you roll over it gets the
blank box instead of gnav_ho_on.gif

I've tried inserting all manner of slashes etc. How does one tell
javascript to use src's relative to the site's root?
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stuart Scharf | last post by:
I have tried to implement a link rollover as described in: http://www.alistapart.com/articles/sprites/ and other references posted on this newsgroup. My attempt resulted in grossly mangled...
3
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
47
by: Lauren Quantrell | last post by:
I have constructed the following code that simulates the common rollover effect when moving the mouse over a label (this example makes the label bold.) I'm wondering if anyone has come up with...
0
by: VB Programmer | last post by:
I used Photoshop/Image Ready to create rollover buttons (for a nav menu). They work great. But, when I take the html, including the javascript and put it in a MasterPage, when I view the page...
3
by: Rob R. Ainscough | last post by:
Just curious why a VERY commonly used affect of rollover was NOT implemented in .NET 2.0 for web controls? Does anyone have a link to VB code that will show me how to build my own UserControl...
5
by: baden | last post by:
I can't figure out why 'display' in the main method wont show in my output. Any help will be appreciated. import javax.swing.JOptionPane; public class lab006 { ...
5
by: lofty | last post by:
Hi, I'm building a time report system for work and I want to show the total hours and minutes a project have taken but can't get it to work ... I have a database (MySQL) in one table I have...
3
by: Oriane | last post by:
Hi there, I would like to handle a "rollover" <asp:Buttonin the code behind with C# with this kind of code: Button btn = Page.FindControl("Button" + numWidget) as Button; btn.Attributes =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.