473,320 Members | 1,724 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,320 software developers and data experts.

Image opacity flicker and getElementById

I am writing a small script to fade the opacity of an image/object.
The script itself works fine only I do have some unwanted behaviour.

I do use a tablecell object and the mouseover/mouseout to activate the
script.
In the same cell are some links listed and when you move the cursor
over the links the image starts to flicker. This is because of the
getElementById that identifies each link as an object.

Anyone knows how I can solve this behaviour?
(Below is the sourcecode I use)

Thanks a lot for your help in advance.
Maurice Hoeneveld
mh********@zonnet.nl

<HTML>
<HEAD>
<TITLE></TITLE>

<SCRIPT language="JavaScript1.2">
<!--

function opacity(id, opacStart, opacEnd, milisec) {
// speed for each frame
var speed = Math.round(milisec / 100 );
var timer = 0;

// determine the direction for the blending, if start and end are the
same nothing happens
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
} else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++) {
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
}
}

// change the opacity for different browsers
function changeOpac(opacity, id) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}
//-->
</SCRIPT>

</HEAD>
<BODY BGCOLOR=#AAAAAA>
<CENTER>
<TABLE BORDER=0 WITH=800>
<TR>
<TD WIDTH=200 VALIGN=top id="image1"
STYLE="filter:alpha(opacity=50);-moz-opacity:0.5"
onMouseover="opacity('image1',50,100,2000)"
onMouseout="opacity('image1',100,50,2000)"
<CENTER>

<IMG SRC="image1.jpg" width=200 height=150 BORDER=0><BR>
<A HREF="link1.html" TARGET=_BLANK>link1<BR>
<A HREF="link2.html" TARGET=_BLANK>link2<BR>
<A HREF="link3.html" TARGET=_BLANK>link3<BR>
<A HREF="link4.html" TARGET=_BLANK>link4<BR>
<A HREF="link5.html" TARGET=_BLANK>link5<BR>
<A HREF="link6.html" TARGET=_BLANK>link6<BR>
</CENTER>
</TD>
</TR>
</TABLE>
</CENTER>

</BODY>
</HTML>

May 2 '06 #1
1 2610

mhoeneveld wrote:
I am writing a small script to fade the opacity of an image/object.
The script itself works fine only I do have some unwanted behaviour.

I do use a tablecell object and the mouseover/mouseout to activate the
script.
In the same cell are some links listed and when you move the cursor
over the links the image starts to flicker. This is because of the
getElementById that identifies each link as an object.


Actually, I think the cause is that hovering the links is triggering
mouseout events for the table cell. You could re-code the function so
that once a transition has started, it cannot be halted.

--
S.C.

May 3 '06 #2

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

Similar topics

4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
6
by: Bryan | last post by:
Hello all, I have an image that is set up like a table of smaller images. Instead of just creating the smaller images separately and putting them together with a table or CSS, I decided to just...
6
by: jesper_lofgren | last post by:
Hi, I wonder if its possible to show and hide a image with javascipt. I want the image to disapear from bottom and up very smooth, maybe under 3-4sec. Is it possible ? any tips ? Thanks
1
by: Romulo NF | last post by:
Greetings everyone, I´ve developed a script to make a slideshow using a holder and the images you need. Just place the images you need within a holder, pass the holder ID to the script and its...
16
by: Darko | last post by:
Hi, I'm trying to get and set an element's opacity, but I'm stuck with, what a hell of surprise, Internet Explorer. As for getting the element's opacity, I have the following (not working) lines...
15
by: Sunny | last post by:
Hi, I can change the lement opacity in IE using. abc.style.filter = 'alpha(opacity=' + 10 + ')'; But this dont work in firefox, In firefox it throws error. How I can change the opacity of an...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.