473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help Make This Mozilla Compartible

6 New Member
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 1578
Dayo
6 New Member
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 New Member
Scratch the post above...it doesn't work

Help please!
Jul 19 '07 #3
epots9
1,351 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Moderator Expert
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 New Member
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 New Member
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
10721
by: Peter Diedrich | last post by:
The site design is pretty simple: ============================================ | Head | ============================================ | | | | | | | | | left | center | right | | | | | | | | |
21
2818
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
2
1645
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.
4
1805
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...
17
1583
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!!
28
10275
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
32
2524
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...
112
4760
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"...
8
1466
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
0
9619
marktang
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...
0
10103
jinu1996
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...
1
10038
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,...
0
6713
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();...
0
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
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...

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.