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

Please Help Make This Mozilla Compartible

6
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. }
  5.  
  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. }
  22.  
  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. }
  31.  
  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. }
  38.  
  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. }
  49.  
  50. function setOpacity(obj, opacity) {
  51.     opacity = (opacity == 100)?99.999:opacity;
  52.  
  53.     // IE/Win
  54.     obj.style.filter = "alpha(opacity:"+opacity+")";
  55.  
  56.     // Safari<1.2, Konqueror
  57.     obj.style.KHTMLOpacity = opacity/100;
  58.  
  59.     // Older Mozilla and Firefox
  60.     obj.style.MozOpacity = opacity/100;
  61.  
  62.     // Safari 1.2, newer Firefox and Mozilla, CSS3
  63.     obj.style.opacity = opacity/100;
  64. }
  65.  
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 1543
Dayo
6
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.


Expand|Select|Wrap|Line Numbers
  1. function setOpacity(obj, opacity) {
  2.     opacity = (opacity == 100)?99.999:opacity;
  3.  
  4.     // IE/Win
  5.     obj.style.filter = "alpha(opacity:"+opacity+")";
  6.  
  7.     // Safari<1.2, Konqueror
  8.     obj.style.KHTMLOpacity = opacity/100;
  9.  
  10.     // Older Mozilla and Firefox
  11.     obj.style.MozOpacity = opacity/100;
  12.  
  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;
  17.  
  18. }
  19.  
I know from online resources that the code is wrong so still hoping for help towrdds a proper solution.

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

Help please!
Jul 19 '07 #3
epots9
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;
  3.  
  4.     // IE/Win
  5.     obj.style.filter = "alpha(opacity:"+opacity+")";
  6.  
  7.     // Safari<1.2, Konqueror
  8.     obj.style.KHTMLOpacity = opacity/100;
  9.  
  10.     // Older Mozilla and Firefox
  11.     obj.style.-moz-opacity = opacity/100;
  12.  
  13.     // Safari 1.2, newer Firefox and Mozilla, CSS3
  14.     obj.style.opacity = opacity/100;
  15. }
  16.  
good luck
Jul 19 '07 #4
Dayo
6
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.
Jul 19 '07 #5
gits
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
Dayo
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
Dayo
6
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

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

82
by: Peter Diedrich | last post by:
The site design is pretty simple: ============================================ | Head | ============================================ | | ...
21
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...
2
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...
4
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...
17
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...
28
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...
32
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...
112
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...
8
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.