Nov 22, 2009

Snow Script,I works well both in IE and FireFox

free web hosting
Open Discussion > xisT-O-Rama > Life Talk > General Talk

Snow Script,I works well both in IE and FireFox

Minisheep
I have seen the post here.http://freenukehosting.com/forums/viewtopic.php?t=889
It's really good,but it can't work in Mozilla FireFox,So I edit the code,and add a image.

Save the code as file snow.js
CODE


/*下雪snow - Start*/

var no = 10; // number of snows

var speed = 20; // smaller number moves the snows faster

var heart = "images/snow.gif";

var flag = new Array();

var ns4up = (document.layers) ? 1 : 0; // browser sniffer

var ie4up = (document.all) ? 1 : 0;

var dom = (document.getElementById) ? 1 : 0;

// coordinate and position variables

var dx = new Array();

var xp = new Array();

var yp = new Array();

// amplitude and step variables

var amx = new Array();

var amy = new Array();

var stx = new Array();

var sty = new Array();

var i, doc_width = 800, doc_height = 600;

if (ie4up) {

doc_width = document.body.clientWidth;

doc_height = document.body.scrollTop+document.body.clientHeight;

}

else {

doc_width = window.innerWidth;

doc_height = window.pageYOffset+window.innerHeight;

}

for (i = 0; i < no; ++ i) {

dx[i] = 0; // set coordinate variables

xp[i] = Math.random()*(doc_width-30)+10; // set position variables

yp[i] = Math.random()*doc_height;

amy[i] = 12+ Math.random()*20; // set amplitude variables

amx[i] = 10+ Math.random()*40;

stx[i] = 0.02 + Math.random()/10; // set step variables

sty[i] = 0.7 + Math.random(); // set step variables

flag[i] = (Math.random()>0.5)?1:0;

if (ns4up) { // set layers

 document.write("<layer id="dot"+ i +"" name="dot"+ i +"" left="150" top="150" visibility="show"><img src="" + heart+ "" border="0"></layer>");

}

else{

 document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 150px; LEFT: 150px;"><img src="" + heart+ "" border="0"></div>");

}

}

function snow(){

for (i = 0; i < no; ++ i) { // iterate for every dot

 if (yp[i] > doc_height-50) {

  xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);

  yp[i] = 0;

  stx[i] = 0.02 + Math.random()/10;

  sty[i] = 0.7 + Math.random();

  flag[i]=(Math.random()<0.5)?1:0;

  if (ie4up) {

   doc_width = document.body.clientWidth;

   doc_height = document.body.clientHeight;

  }

  else{

   doc_width = window.innerWidth;

   doc_height = window.innerHeight;

  }

 }

 if (flag[i])

  dx[i] += stx[i];

 else

  dx[i] -= stx[i];

 if (Math.abs(dx[i]) > Math.PI) {

  yp[i]+=Math.abs(amy[i]*dx[i]);

  xp[i]+=amx[i]*dx[i];

  dx[i]=0;

  flag[i]=!flag[i];

 }

 idot="dot"+i;

 c=(dom)? document.getElementById(idot).style : (ie4up)? document.all[idot].style : (ns4up)? document.layers[idot] : "";

 theTop=yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));

 theLeft=xp[i] + amx[i]*dx[i];

 if (ns4up) {

  c.top=theTop;

  c.left=theLeft;

 }

 else if(ie4up){

  c.pixelTop=theTop;

  c.pixelLeft=theLeft;

 }

 else if(dom){

  c.top=theTop+"px";

  c.left=theLeft+"px";

 };

}

}

/*下雪 snow - End*/

window.setInterval("snow()", speed);//下雪,snow


Also you can change the path of the snow image.You can get the image here.user posted image
http://www.freewebs.com/yang1984/snow.gif
And the code below after <body> tag.
CODE


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



You can get a demo here.
http://www.freewebs.com/yang1984/snow.html

 

 

 


Comment/Reply (w/o sign-up)

clffworld
thanks!
let me try.

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : snow, script, works, firefox

  1. Firefox The Most Unstable Browser?
    (10)
  2. Ipb/firefox Problem
    (6)
    This has me a bit stumped, when using either of my Firefox versions (1.5 & 2.2) in here now it
    takes an age for the characters to appear when I type. I thought it may have been a plugin which
    was affecting things, but most of my the plugins for 1.5 dont work with 2.2 yet, so it cant be
    that as both versions have the same problem. I've cleared cache/cookies/clear all cookies set
    by this board, restarted twice - once in safe mode, but its still the same. It only happens on
    IPB forums, and only in the text entry box - not in the title/description boxes. ....
  3. 'stumbleupon' Firefox Addon - The Future Of The Internet
    (7)
    The future of internet browsing is here! I installed this about 4 hours ago & havnt been able to
    leave it since. Basically, you install the extension, select what kind of sites you like, & click
    the 'stumble' button in your toolbar. It is highly addictive, I seen things that id never
    dream of looking for before, all utterly brilliant. If you find something you dont like, click the
    thumbs down button & similar sites will never bother you again. To give you an idea of some of the
    things I come across, check these out: http://www.everyvideogame.com/ (you name ....
  4. Tell Me How Religion Works, Please?
    Religion (3)
    All of you following a religion, what's so good about it? What's so good about following a
    bunch of morals that aren't your own? In my opinion, people shouldn't even be allowed to be
    in a religion until they turn 18. Want to know why? Because religion means absolutely nothing if
    you're born into it. Think about it...if you're Christian right now, do you really think you
    would be Christian if your parents weren't? (Same with Moslem, Buddhists, Jewish, every
    religion!). Life is about being your own person and living for yourself. Not living f....
  5. Firefox Vs Internet Explorer .
    (4)
    FireFox vs internet Explorer . what do you Think . for me I think FireFox is the best /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> . Please read the following
    post : http://www.trap17.com/forums/index.php?s=&...ndpost&p=259578 Dont forget to search the
    forums! ....
  6. Mozilla FireFox
    (8)
    Hello, My new browser is FireFox now, but when I click a link, internet explorer automatic
    opens or my inbox in msn. My standard browser is FireFox now but why does that opens all the
    time??? Soz for my bad english....
  7. Firefox roadmap to 2.0
    (8)
    http://www.mozilla.org/projects/firefox/roadmap.html The roadmap to perfection, personally I
    think firefox is perfect. There are some changes that need to be made in parsing css and javascript
    compatibility but for the rest it's pretty much perfect just the way it is. Good luck to those guyz.
    17.8mil downloads estimated. /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> ....
  8. How to create a dynamic navigation bar using simple scripti
    (4)
    This short, but consise tutorial presents how to create a dynamic navigation bar using simple
    scripting verses using an image roll-over script. Using text instead of images offers 3 benefits
    while sacrificing only a little in design. The end resault is a navigation bar that looks great,
    dosen't bog the server down with images, loads fast, and is search engine friendly. In addition, you
    save time by not having to design two images for every link required. Using simple combination of
    Html, CSS, and Javascript we are able to create links in which both the color of the....
  9. regarding Firefox from Mozilla....
    (22)
    some questions..... I have installed Firfox, and is trying it out and i´ve search the links on
    the subject "firefox", but do need some answers on these... On Explorer i have following
    integrated.... -convert and open -flash capture -flash get -system and internet washer -my
    mobiles ( pda... ) i can probably read about it on some official links on Mozilla.org..., but
    does someone here have some personal experience... ? __________________....
  10. FireFox
    (2)
    Okay, who beleives that FireFox is the best bloody program out there? I DO I DO!! ><....
  11. Question about Firefox
    (3)
    I installed it again (on a new computer) and now there is a bar across the top for my "favorites" I
    deleted the favorites from the bar but it is still there. Now I have a big empty rectangle across
    the top of my browser. Tell me how to remove it please.....
  12. Firefox
    (29)
    What do you think about it. Personaly i think its good but a tiny bit slow....
  13. FireFox problems: Is it the worst browser?
    (33)
    Most-heard complaints People didn't understand the interface Sometimes, it reacted so slow, people
    thought the network had crashed or the internet connection was down It freezed and crashed
    constantly, sometimes sucking more than 90% of the CPU load for no obvious reason Pages showed up
    completely wrong or didn't work at all Wanted pop-ups didn't open Completed downloads could not be
    found Bookmarking gave problems PDF-files caused crashing Pages "disappeared" by accidentally
    using tabular browsing Lots of obvious keyboard- and mouse shortcuts were missing …an....
  14. Spreading Firefox, place an information bar in IE
    (13)
    If you are using IE to browse the web you may be seeing the information bar pops up and tell you to
    switch to Firefox. It's very cool, I think many Firefox fans here will admire it. So I post my code
    here for you Firefox fans. It is free to redistribute or modifying as long as you keep the credits.
    It is multilingual and will show the language that you are currently using. It now has 6+ languages
    and I expect to have more. CODE Credits: HTML & CSS code by Martin Ng PHP code by
    Ching Yonghan English message by Lim Chee Aun modified by Ching Yonghan Mal....
  15. Firefox Images
    (19)
    If you find any firefox images or and Anit-EI images for that matter, post them here, Ive fond a
    few, I think thay are quite good myself, i like the first one the most.... Tell me what you think of
    thses and post any that you find... Dont worry guys, we'll get them all soon...
    /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> I love these images.......
  16. Do U Think Firefox Loads Pic Slower ?
    let's vote on this (14)
    I've found that pics are loaded slower in Firefox compared to IE What do u think ?....
  17. Firefox and CSS
    Whats up with firefox browser (17)
    Does anyone know why CSS does not work well with the firefox browser.......

    1. Looking for snow, script, works, firefox

Searching Video's for snow, script, works, firefox
See Also,
advertisement


Snow Script,I works well both in IE and FireFox

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com