Solved

Jquery fadein Blinking in IE8 browser due to Doctype

Posted on 2013-05-10
6
497 Views
Last Modified: 2013-05-15
I have a slide show that I have created using jquery's fadein/fadeout.
It works in all browsers except Internet Explorer 8

Problem: ( IE8 only )
The images are blinking instead of fading in and out

Work done:
I know it has to do with the Doctype, because if i remove it, the jquery works fine.
But then the CSS Styles will not work.

So if I have the Doctype - CSS works / Jquery does not
If I dont have the Doctype - Jquery works / CSS does not

I have tried all types of transitional/strict Doctypes, none of them works.

Anyone have a solution or simple Jquery Fadein/Fadeout for this?

All I am trying to do is have a simple .fadein/.fadeout of 4 images using Jquery.

Thanks in advance

<!DOCTYPE>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$('.fadein p:gt(0)').hide();setInterval(function(){$('.fadein > :first-child').fadeOut().next('p').fadeIn().end().appendTo('.fadein');}, 
<!--change speed-->
    1000
<!--change speed-->
);});
</script>

<style>
#page{margin:0 auto;padding:1%;width:90%;background:red;min-height:450px;}
#left{float:left;width:48%;background:blue;}
#right{float:right;width:48%;background:lime}
.fadein { position:relative;}
.fadein p { position:absolute;top:0;right:0;bottom:0;left:0;}
.fadein img {width:100%;max-height:350px;}
</style>

<p>top of webpage here</p>

<div id="page">
<div id="left">hello lefty</div>
<div id="right">
<div class="fadein">
<p><img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg"></p>
<p><img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg"></p>
<p><img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg">image3</p>
</div></div>
</div>


<p>bottom of page here</p>

Open in new window

0
Comment
Question by:webdott
  • 3
  • 3
6 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39156907
If that is your actual web page, there are many things wrong with it.  Incomplete DOCTYPE, no <head> section, no <body> section.  This is what it should be at a very minimum for it to work predictably.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$('.fadein p:gt(0)').hide();setInterval(function(){$('.fadein > :first-child').fadeOut().next('p').fadeIn().end().appendTo('.fadein');}, 
<!--change speed-->
    1000
<!--change speed-->
);});
</script>

<style>
#page{margin:0 auto;padding:1%;width:90%;background:red;min-height:450px;}
#left{float:left;width:48%;background:blue;}
#right{float:right;width:48%;background:lime}
.fadein { position:relative;}
.fadein p { position:absolute;top:0;right:0;bottom:0;left:0;}
.fadein img {width:100%;max-height:350px;}
</style>
</head>
<body>
<p>top of webpage here</p>

<div id="page">
<div id="left">hello lefty</div>
<div id="right">
<div class="fadein">
<p><img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg"></p>
<p><img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg"></p>
<p><img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg">image3</p>
</div></div>
</div>

<p>bottom of page here</p>
</body>
</html>

Open in new window

0
 

Author Comment

by:webdott
ID: 39156936
Thanks for that. I was showing the stripped down code.

Even with the complete code in, it does not work.
The CSS works, but the fadein jquery BLINKS instead of FADING

If I remove the <!DOCTYPE html>
the JQUERY FADEIN/OUT works
but the CSS does not work

The problem I am trying to solve is for them Both to work.

Thanks, but that does not fix the problem.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39157062
I doubt that we can provide a solution with what you have shown us.  Can you give us a link to the page so we can check it out?

PS:  I just noticed you said Internet Explorer 8.  IE8 does not support the HTML5 DOCTYPE.  You will need to use an earlier DOCTYPE if that is important.  http://www.w3.org/QA/2002/04/valid-dtd-list.html
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Accepted Solution

by:
webdott earned 0 total points
ID: 39157179
Thanks, but I fixed it.

I needed to get rid of the <p> and change my script and style to be <img> instead.
It was having issues with trying to style and run the <p> paragraph.

I could have changed it all to a <div> but why add more code.

here is the final code for anyone in the future:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$('.fadein img:gt(0)').hide();setInterval(function(){$('.fadein > :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');}, 
<!--change speed-->
    1000
<!--change speed-->
);});
</script>


<style>
#page{margin:0 auto;padding:1%;width:90%;background:red;min-height:450px;}
#left{float:left;width:48%;background:blue;}
#right{float:right;width:48%;background:lime}
.fadein { position:relative;}
.fadein img {width:100%;max-height:350px;position:absolute;}
</style>
</head>
<body>
<p>top of webpage here</p>

<div id="page">
<div id="left">hello lefty</div>
<div id="right">
<div class="fadein">
<img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg">
<img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg">
<img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg">
</div></div>
</div>

<p>bottom of page here</p>
</body>
</html>

Open in new window

0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 39157185
Cool then, glad you fixed it.
0
 

Author Closing Comment

by:webdott
ID: 39167428
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now