Solved

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

Posted on 2011-03-10
10
595 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

688 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