Hello folks.
Sorry if this seems a bit silly, I have no experience with this type of code.
Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not with Firefox and Netscape. Actually, when I say it doesn't work, I mean you have to refresh the page before the fade happens and once that is done once, it works on that image. for that session.
Here is the code: -
// Fade In Script
-
if (document.getElementById) {
-
document.write("<style type='text/css'>.giThumbImage img {visibility:hidden;} #gsSingleImageId img {visibility:hidden;} </style>");
-
}
-
-
function start() {
-
if (ThumbMatrix = document.getElementById('gbThumbMatrix')) {
-
rowColl = ThumbMatrix.getElementsByTagName('tr');
-
var ImageNumber = 0;
-
for (var r = 0; r < rowColl.length; r++) {
-
var itemColl = rowColl[r].getElementsByTagName('td');
-
for (var i = 0; i < itemColl.length; i++) {
-
var itemClass = itemColl[i].className;
-
if (itemClass == 'gbItemImage' || itemClass == 'gbItemAlbum') {
-
SOME CODE
-
CheckIfComplete(theimage.id, ImageNumber);
-
}
-
}
-
}
-
}
-
}
-
-
function CheckIfComplete(ImageId,ImageNumber) {
-
ImageObj = document.getElementById(ImageId);
-
if (ImageObj.complete == false) {
-
window.setTimeout("CheckIfComplete('"+ImageId+"')", 100);
-
} else {
-
startFade(ImageId,ImageNumber);
-
}
-
}
-
-
function startFade(imageId,ImageNumber) {
-
var ImageFromId = document.getElementById(imageId);
-
setOpacity(ImageFromId, 0);
-
ImageFromId.style.visibility = 'visible';
-
window.setTimeout("fadeIn('" + imageId + "', 0)", (ImageNumber*600));
-
}
-
-
function fadeIn(objId,opacity) {
-
if (document.getElementById) {
-
obj = document.getElementById(objId);
-
if (opacity <= 100) {
-
setOpacity(obj, opacity);
-
opacity += 5;
-
window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
-
}
-
}
-
}
-
-
function setOpacity(obj, opacity) {
-
opacity = (opacity == 100)?99.999:opacity;
-
-
// IE/Win
-
obj.style.filter = "alpha(opacity:"+opacity+")";
-
-
// Safari<1.2, Konqueror
-
obj.style.KHTMLOpacity = opacity/100;
-
-
// Older Mozilla and Firefox
-
obj.style.MozOpacity = opacity/100;
-
-
// Safari 1.2, newer Firefox and Mozilla, CSS3
-
obj.style.opacity = opacity/100;
-
}
-
I understand after Googling this issue that the fade into each other thing needs the image to be stored in the cache before it works which from my understanding of this code is why the writer checks whether the image has loaded function CheckIfComplete () before running the actual fade script.
Now for some reason, I suspect Firefox and Netscape do not ever return a "true" in that function and that it perhaps times out (looking at the code sugests it will go into a perpetual loop if my theory is true. Anyway, I just suspect and wonder if you guys that cast your experienced eyes over this and give some clues to fixing it.
Thanks for your assistance
7 1578
UPDATE
Adding the code in bold type below actually makes it work somewhat. It doesn't fade in but at least it loads the images rather than stop as before. -
function setOpacity(obj, opacity) {
-
opacity = (opacity == 100)?99.999:opacity;
-
-
// IE/Win
-
obj.style.filter = "alpha(opacity:"+opacity+")";
-
-
// Safari<1.2, Konqueror
-
obj.style.KHTMLOpacity = opacity/100;
-
-
// Older Mozilla and Firefox
-
obj.style.MozOpacity = opacity/100;
-
-
// Safari 1.2, newer Firefox and Mozilla, CSS3
-
obj.style.opacity = opacity/100;
-
// Firefox Hack
-
obj.style.-moz-opacity = opacity/100;
-
-
}
-
I know from online resources that the code is wrong so still hoping for help towrdds a proper solution.
Thanks
Scratch the post above...it doesn't work
Help please!
epots9 1,351
Recognized Expert Top Contributor
give this a shot: -
function setOpacity(obj, opacity) {
-
opacity = (opacity == 100)?99.999:opacity;
-
-
// IE/Win
-
obj.style.filter = "alpha(opacity:"+opacity+")";
-
-
// Safari<1.2, Konqueror
-
obj.style.KHTMLOpacity = opacity/100;
-
-
// Older Mozilla and Firefox
-
obj.style.-moz-opacity = opacity/100;
-
-
// Safari 1.2, newer Firefox and Mozilla, CSS3
-
obj.style.opacity = opacity/100;
-
}
-
good luck
epots9
Thanks for the reply.
That seems to get it to stumble through and display the image without the blend just like the post I made above.
The error console returns an error and the way the page progresses appears very jerky.
It still seems the issue is with the checkifcomplete function and that somehow the mozilla type browsers (apart from Safari...I am on a Mac) are not responding the the ?.complete test.
This is my gut feel and wonder if there is a way to validate this or to work around this.
Thanks for your help.
gits 5,390
Recognized Expert Moderator Expert
hi ...
i'm wondering whether this may work: - obj.style.-moz-opacity = opacity/100;
try the following instead: - obj.style['-moz-opacity'] = opacity/100;
kind regards
I have been searching everywhere like mad and came up with this http://www.thescripts.com/forum/thread626745.html.
Don't fully understand what they are saying but it seems to confirm my suspicion that the ?.complete test is not always answered truthfully.
Any assisstance will be greatly appreciated.
YEEEEEHAAAAAAAA !!!!!!!!!!!!!!! !
It's the triumph of the noob.
After about 18 hours of Google and so forth, I finally found the solution.
It was function CheckIfComplete as I suspected and changing it to the following -
function CheckIfComplete(ImageId,ImageNumber) {
-
Window.onload = startFade(ImageId,ImageNumber);
-
}
-
gets it to works on all browsers including Opera which was totally snafued before...for now.
Got a few enhancements to apply and happy I have a fall back if those don't work.
Now for some sleep.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter Diedrich |
last post by:
The site design is pretty simple:
============================================
| Head |
============================================
| | | |
| | | |
| left | center | right |
| | | |
| | | |
|
by: Applebrownbetty |
last post by:
Hi, I've run into a problem with IE 6 vs. Mozilla when displaying a
completely CSS positioned page, and was wondering if any resident CSS guru
might quickly be able to find the problem(s). Thank you.
In IE, the page looks how I want it to look (picture below):
www.sunbadgeco.com/sunmetal/ie.jpg
In Mozilla Firefox, somehow it's not quite right (pic below):
www.sunbadgeco.com/sunmetal/mozillafirefox.jpg
|
by: TAM |
last post by:
Hi,
I have redesigned one html page by removing all the tables. You can
see this test page at http://www.ngrain.com/css/home1.htm. Only
home1.htm has been redesigned without tables. Rest of the site uses
tables for layout.
I would appreciate if you can take a look at this page and CSS and
comment on the coding.
|
by: Derek |
last post by:
I have the following script in a page and it gets an error in IE 6. Says
something about an invalid
argument but the line number doesn't help since I can't see the javascript
code when viewing source.
I have this script in a popup page where the user selects a user ID (id) and
that value is then placed
into one of the parent window's form text field called "userId". This
script works fine in the latest
Mozilla and Mozilla Firefox but...
|
by: Joe |
last post by:
I'm a long-time lurker, so I know what to expect!
Can someone please look at this and make appropriate comments?
http://members.aardvark.net.au/grakat/temp/
It's only four pages, and it should pretty much work
If someone can help me out with the 'form' on the contact page (which I
copied) I'd be grateful. PLEASE DON'T USE THE FORM TO SEND ANYTHING TO
ME. At the moment, the addy it points to is disabled!!
| |
by: Tim_Mac |
last post by:
hi,
i'm new to .net 2.0, and am just starting to get to grips with the
gridview.
my page has autoEventWireUp set to true, which i gather is supposed to
figure out which handlers to invoke when appropriate based on your
method names .
the GridView has OnRowCommand="GridView1_RowCommand" in the aspx.
my problem is that the RowCommand event is firing twice (95% of the
time) on the page. the other 5% it only fires once. there's no
|
by: Tom Cole |
last post by:
I bet 50% of the posts I've read lately have had at least one bad thing
to say about every website or book dedicated to javascript.
There are clearly a few posters (you know who you are) who either are
or consider themselves to be the "comp.land.javascript elite". You guys
may be the brightest, most seasoned developers out there, and hats off
to you. You may not be, how the heck would I know. But...
Not to be too critical (which sounds...
|
by: Prisoner at War |
last post by:
Friends, your opinions and advice, please:
I have a very simple JavaScript image-swap which works on my end but
when uploaded to my host at http://buildit.sitesell.com/sunnyside.html
does not work.
To rule out all possible factors, I made up a dummy page for an
index.html to upload, along the lines of <html><head><title></title></
head><body></body></html>.; the image-swap itself is your basic <img
src="blah.png"...
|
by: Tim Nash (aka TMN) |
last post by:
Hi
Can anyone help me match this div below - my regex does not work - if
you could tell me why I would appreciate it.
var aStr = "<div class='feedflare'>dfgdg dg</div>";
var reg = new RegExp("<div class='feedflare'.*?</div>'","gim");
thanks
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |