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

Please Help Make This Mozilla Compartible

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:

Expand|Select|Wrap|Line Numbers
  1. // Fade In Script 
  2. if (document.getElementById) {
  3.     document.write("<style type='text/css'>.giThumbImage img {visibility:hidden;} #gsSingleImageId img {visibility:hidden;} </style>");
  4. }
  6. function start() {
  7.     if (ThumbMatrix = document.getElementById('gbThumbMatrix')) {
  8.     rowColl = ThumbMatrix.getElementsByTagName('tr');
  9.     var ImageNumber = 0;
  10.     for (var r = 0; r < rowColl.length; r++) {
  11.         var itemColl = rowColl[r].getElementsByTagName('td');
  12.         for (var i = 0; i < itemColl.length; i++) {
  13.         var itemClass = itemColl[i].className; 
  14.         if (itemClass == 'gbItemImage' || itemClass == 'gbItemAlbum') {
  15.            SOME CODE
  16.             CheckIfComplete(theimage.id, ImageNumber);
  17.         }
  18.         }
  19.     }
  20.     }
  21. }
  23. function CheckIfComplete(ImageId,ImageNumber) {
  24.     ImageObj = document.getElementById(ImageId);
  25.     if (ImageObj.complete == false) {
  26.     window.setTimeout("CheckIfComplete('"+ImageId+"')", 100);
  27.     } else {
  28.     startFade(ImageId,ImageNumber);
  29.     }
  30. }
  32. function startFade(imageId,ImageNumber) {
  33.     var ImageFromId = document.getElementById(imageId);
  34.     setOpacity(ImageFromId, 0);
  35.     ImageFromId.style.visibility = 'visible';
  36.     window.setTimeout("fadeIn('" + imageId + "', 0)", (ImageNumber*600));
  37. }
  39. function fadeIn(objId,opacity) {
  40.     if (document.getElementById) {
  41.     obj = document.getElementById(objId);
  42.     if (opacity <= 100) {
  43.         setOpacity(obj, opacity);
  44.         opacity += 5;
  45.         window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
  46.     }
  47.     }
  48. }
  50. function setOpacity(obj, opacity) {
  51.     opacity = (opacity == 100)?99.999:opacity;
  53.     // IE/Win
  54.     obj.style.filter = "alpha(opacity:"+opacity+")";
  56.     // Safari<1.2, Konqueror
  57.     obj.style.KHTMLOpacity = opacity/100;
  59.     // Older Mozilla and Firefox
  60.     obj.style.MozOpacity = opacity/100;
  62.     // Safari 1.2, newer Firefox and Mozilla, CSS3
  63.     obj.style.opacity = opacity/100;
  64. }
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
Jul 19 '07 #1
7 1535

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.

Expand|Select|Wrap|Line Numbers
  1. function setOpacity(obj, opacity) {
  2.     opacity = (opacity == 100)?99.999:opacity;
  4.     // IE/Win
  5.     obj.style.filter = "alpha(opacity:"+opacity+")";
  7.     // Safari<1.2, Konqueror
  8.     obj.style.KHTMLOpacity = opacity/100;
  10.     // Older Mozilla and Firefox
  11.     obj.style.MozOpacity = opacity/100;
  13.     // Safari 1.2, newer Firefox and Mozilla, CSS3
  14.     obj.style.opacity = opacity/100;
  15.     // Firefox Hack
  16.     obj.style.-moz-opacity = opacity/100;
  18. }
I know from online resources that the code is wrong so still hoping for help towrdds a proper solution.

Jul 19 '07 #2
Scratch the post above...it doesn't work

Help please!
Jul 19 '07 #3
1,351 Expert 1GB
give this a shot:
Expand|Select|Wrap|Line Numbers
  1. function setOpacity(obj, opacity) {
  2.     opacity = (opacity == 100)?99.999:opacity;
  4.     // IE/Win
  5.     obj.style.filter = "alpha(opacity:"+opacity+")";
  7.     // Safari<1.2, Konqueror
  8.     obj.style.KHTMLOpacity = opacity/100;
  10.     // Older Mozilla and Firefox
  11.     obj.style.-moz-opacity = opacity/100;
  13.     // Safari 1.2, newer Firefox and Mozilla, CSS3
  14.     obj.style.opacity = opacity/100;
  15. }
good luck
Jul 19 '07 #4
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.
Jul 19 '07 #5
5,390 Expert Mod 4TB
hi ...

i'm wondering whether this may work:

Expand|Select|Wrap|Line Numbers
  1. obj.style.-moz-opacity = opacity/100;
try the following instead:

Expand|Select|Wrap|Line Numbers
  1. obj.style['-moz-opacity'] = opacity/100;
kind regards
Jul 19 '07 #6
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.
Jul 19 '07 #7

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

Expand|Select|Wrap|Line Numbers
  1. function CheckIfComplete(ImageId,ImageNumber) {
  2.     Window.onload = startFade(ImageId,ImageNumber);
  3. }
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.
Jul 20 '07 #8

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 | ============================================ | | ...
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...
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...
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...
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...
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...
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...
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...
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...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.