?
Solved

CSS & Jquery script to fade in images and rollover fades Not working in IE

Posted on 2011-03-10
10
Medium Priority
?
598 Views
Last Modified: 2012-06-27
Hi,

Having real problems trying to display this test page properly in IE 8,7,&6 and can't figure out why?
Really could use some help tracking this down as it works perfectly in all other browsers I've tested (Safari Opera Chrome Firefox)
thanks
0
Comment
Question by:sany101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 13

Expert Comment

by:darren-w-
ID: 35094020
ie uses somthing different to Opcity:

http://www.w3schools.com/css/css_image_transparency.asp

ie: filter:alpha(opacity=x).
0
 

Author Comment

by:sany101
ID: 35094364
Well I guess I'm missing something because this example which is which is what I was using in my test works perfectly all the way back to I.E 6?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35094633
Your right:

this works though in ie8:(have taken the heights out of the image definitions)
<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

                position:absolute;
            }
            #galleryHolder {
                width:354px;
            }
            /* Hover Fade Styling */
            div.fadeHoverGallery {
                margin:10px;
                position: relative;
                width: 334px;
                height: 176px;
            }
            img.a {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                z-index: 10;
            }
            img.b {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
            }

        </style>
        <!-- scripts -->


        <!-- On Load Fade -->

        <!-- Roll Over Fade -->
        <script type='text/javascript'>
            $(function(){

                $("img.a").hover(
                function() {
                    $(this).stop().animate({"opacity": "0"}, "slow");
                },
                function() {
                    $(this).stop().animate({"opacity": "1"}, "slow");
                });

            });
        </script>
    </head>
    <body>
        <div id="galleryHolder">
            <div class="gallery"><div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg" class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg"  class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <!-- end gallery --></div>
            <!-- end galleryHolder --></div>
    </body>
</html>

Open in new window

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 13

Expert Comment

by:darren-w-
ID: 35094658
Works fine in ie6 too

Darren
0
 

Author Comment

by:sany101
ID: 35094738
Thanks Darren, however I still need the images to fade on load which you've removed:

<script type="text/javascript">
$(function(){
	$(".gallery").preloader();
	
	});

Open in new window


0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35095260
I've used this preloader instead, it works with ie:

http://flesler.blogspot.com/2008/01/jquerypreload.html


<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

                position:absolute;
            }
            #galleryHolder {
                width:354px;
            }
            /* Hover Fade Styling */
            div.fadeHoverGallery {
                margin:10px;
                position: relative;
                width: 334px;
                height: 176px;
            }
            img.a {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                z-index: 10;
            }
            img.b {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
            }

        </style>

        <script type="text/javascript" src="preload.js"></script>

        <script type='text/javascript'>
            $(function(){
                $.preload(".gallery");
                $("img.a").hover(
                function() {
                    $(this).stop().animate({"opacity": "0"}, "slow");
                },
                function() {
                    $(this).stop().animate({"opacity": "1"}, "slow");
                });

            });
        </script>
    </head>
    <body>
        <div id="galleryHolder">
            <div class="gallery"><div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg" class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg"  class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <!-- end gallery --></div>
            <!-- end galleryHolder --></div>
    </body>
</html>

Open in new window

0
 

Author Comment

by:sany101
ID: 35095404
Again thanks Darren but I think you've miss understood what I was using the original pre-load script for. It was to fade the images.
 check out the original test page in firefox to see what I mean.
Thanks
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35095508
Hi,

Where have you got the preloader method from? Its obviously conflicting with the animate effect, perhaps you could look at others that don't conflict?

Busy now but will take a look later.

D
0
 
LVL 6

Accepted Solution

by:
blueghozt earned 2000 total points
ID: 35111532
your preloader definitely borks IE, not sure how

but try a simpler method and maybe tweak the numbers to suit:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
<head>
<style type="text/css">



#galleryHolder {

	width:354px;

}

/* Hover Fade Styling */

div.fadeHoverGallery {

	margin:10px;

	position: relative;

	width: 334px;

	height: 176px;

	}

img.a {

	display:none; 

	position: absolute;

	left: 0;

	top: 0;

    z-index: 10;
	
	border:0;

	}

img.b {

	display:block; 

	position: absolute;

	left: 0;

	top: 0;
	
	border:0;

	}



</style>

<!-- scripts -->

<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>

<script type="text/javascript" src="js/jquery.preloader.js"></script>

<!-- On Load Fade -->


<!-- Roll Over Fade -->

<script type='text/javascript'>

$(document).ready(function(){

	$("img.b").hide();
	$("img.first").fadeIn(2000);
	$("img.second").fadeIn(4000);
	$("img.b").fadeIn(4000);


	$("img.a").hover(

	function() {

	$(this).stop().animate({"opacity": "0"}, "slow");

	},

	function() {

	$(this).stop().animate({"opacity": "1"}, "slow");

	});


});

</script>

</head>

<body>

	<div id="galleryHolder">

		<div class="gallery">

			<div class="fadeHoverGallery">
				<a href="#">
					<img src="images/image_a.jpg" width="334" height="176" class="a first" alt="" />
					<img src="images/image_b.jpg" width="334" height="176" class="b" alt="" />
				</a>	
			</div><!-- end fadeHoverGallery -->

			<div class="fadeHoverGallery">
				<a href="#">
					<img src="images/image_a.jpg" width="334" height="176" class="a second" alt="" />
					<img src="images/image_b.jpg" width="334" height="176" class="b" alt="" />
				</a>
			</div><!-- end fadeHoverGallery -->
		
		</div><!-- end gallery -->
		
	</div><!-- end galleryHolder -->

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:sany101
ID: 35128793
Perfect thanks
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question