0

I've attempted to run several of the "falling snow background" type scripts available at scriptmania. Just javascript, no jquery.

I'm puzzled by the fact that some of them work fine in IE, but fail to animate in FF, Chrome or Safari when the doctype is set to HTML5. The scripts do run in any of the above browsers when the doctype is set to HTML 4.0 Transitional.

Here are links to a couple of scripts that have this behavior:

http://rainbow.arch.scriptmania.com/scripts/bg/snow_fall.html

http://rainbow.arch.scriptmania.com/scripts/bg/autumn_fall_timeout.html

Any pointers as to what might be the root cause of the failures and/or fixes would be appreciated.

5
  • It works for me in Chrome: jsbin.com/ijEcUji/1 Please show exactly how you are setting the doctype, and let us know if the browsers where it doesn't work for you are reporting any errors in their consoles. Commented Sep 22, 2013 at 0:27
  • Looking at that code, it looks to be trying quite hard to be compatible with older browsers. That was probably legitimate at the time it was written, but today browsers are much more standardized. It could be that the script is using something that was allowed in HTML4 for compatibility, but the HTML5 DOCTYPE makes the browser stricter, removing obsolete features. Commented Sep 22, 2013 at 0:29
  • Using <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> or <!DOCTYPE HTML>. Either one followed by <html lang="en">. Commented Sep 22, 2013 at 0:57
  • The jsbin demo I linked to above uses <!DOCTYPE html> and it works in Chrome. Commented Sep 22, 2013 at 1:02
  • nnnnnn - The first link, initially linked up to a script that works. I've edited it to link to one of the scripts that fail. Sorry for the typo. Commented Sep 22, 2013 at 1:07

2 Answers 2

1

The HTML 4.01 Transitional Doctype with no URL component triggers Quirks mode in browsers.

The HTML 5 Doctype triggers standards mode in browsers.

In Quirks mode, numerous bugs of older browsers (from the 1990s) are emulated.

Dependancy on any of these bugs could be the cause of the problem, but the most likely is that something is setting a CSS property which expects a length but giving it a Number. Lengths other than 0 require units (such as 23px).

Sign up to request clarification or add additional context in comments.

Comments

0

Web Oficial:

http://rainbow.arch.scriptmania.com/scripts/bg/snow_fall_2.html

Download:

http://rainbow.arch.scriptmania.com/scripts/bg/snowstorm.js

Code:

<!-- SNOW TAGS START -->

<!-- Copy the <script> tag into your own page(s) for the snow effect. That is all! (No CSS etc. is needed) -->
<script type="text/javascript" src="snowstorm.js"></script>
<!-- now, we'll customize the snowStorm object -->
<script type="text/javascript">
snowStorm.flakesMaxActive = 95; // show more snow on screen at once
snowStorm.snowStick = true; // When false, snow will never sit at the bottom
snowStorm.animationInterval = 33; // 20 = fast + smooth, but 50 = more but slower
</script>

<!-- SNOW TAGS END -->

Open your file snowstorm.js is go line 41

before:

this.zIndex = 0; // CSS stacking order applied to each snowflake

after:

this.zIndex = 1000; // CSS stacking order applied to each snowflake

Problem body layer is can not see the snow to mean 0 is none, so the need to change for 1000 is available see the front of the body shows snow in front.


sry bad english

Merry Christmas 2014 and New years 2015 ;-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.