473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Pl Check any Error in Javascript Program

144 100+
Hai Friends,
I have a javascript program , as a snow a single picture will fall from above to below in the browser.It is worked properly when my friend was using.Sudennly it is not working ,pl correct if there is any error and send me...............

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2.     <HEAD>
  3.  
  4.         <SCRIPT LANGUAGE="JavaScript">


Expand|Select|Wrap|Line Numbers
  1. var no = 25; // snow number
  2. var speed = 10; // smaller number moves the snow faster
  3. //please put some picture in your computer
  4. var snowflake = "C:\Documents and Settings\Admin\Desktop\jesusinside.gif";
  5.  
  6. var ns4up = (document.layers) ? 1 : 0; // browser sniffer
  7. var ie4up = (document.all) ? 1 : 0;
  8. var dx, xp, yp; // coordinate and position variables
  9. var am, stx, sty; // amplitude and step variables
  10. var i, doc_width = 800, doc_height = 600;
  11. if (ns4up) {
  12. doc_width = self.innerWidth;
  13. doc_height = self.innerHeight;
  14. } else if (ie4up) {
  15. doc_width = document.body.clientWidth;
  16. doc_height = document.body.clientHeight;
  17. }
  18. dx = new Array();
  19. xp = new Array();
  20. yp = new Array();
  21. am = new Array();
  22. stx = new Array();
  23. sty = new Array();
  24. for (i = 0; i < no; ++ i) {
  25. dx[i] = 0; // set coordinate variables
  26. xp[i] = Math.random()*(doc_width-50); // set position variables
  27. yp[i] = Math.random()*doc_height;
  28. am[i] = Math.random()*20; // set amplitude variables
  29. stx[i] = 0.02 + Math.random()/10; // set step variables
  30. sty[i] = 0.7 + Math.random(); // set step variables
  31. if (ns4up) { // set layers
  32. if (i == 0) {
  33. document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
  34. document.write("top=\"15\" visibility=\"show\"><img src=\"");
  35. document.write(snowflake + "\" border=\"0\"></layer>");
  36. } else {
  37. document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
  38. document.write("top=\"15\" visibility=\"show\"><img src=\"");
  39. document.write(snowflake + "\" border=\"0\"></layer>");
  40. }
  41. else if (ie4up)
  42.  {
  43. if (i == 0)
  44.  {
  45. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
  46. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  47. document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
  48. document.write(snowflake + "\" border=\"0\"></div>");
  49. else 
  50. {
  51. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
  52. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  53. document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
  54. document.write(snowflake + "\" border=\"0\"></div>");
  55. }
  56. }
  57. }
  58. function snowNS() { // Netscape main animation function
  59. for (i = 0; i < no; ++ i) { // iterate for every dot
  60. yp[i] += sty[i];
  61. if (yp[i] > doc_height-50) {
  62. xp[i] = Math.random()*(doc_width-am[i]-30);
  63. yp[i] = 0;
  64. stx[i] = 0.02 + Math.random()/10;
  65. sty[i] = 0.7 + Math.random();
  66. doc_width = self.innerWidth;
  67. doc_height = self.innerHeight;
  68. }
  69. dx[i] += stx[i];
  70. document.layers["dot"+i].top = yp[i];
  71. document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
  72. }
  73. setTimeout("snowNS()", speed);
  74. }
  75. function snowIE() { // IE main animation function
  76. for (i = 0; i < no; ++ i) { // iterate for every dot
  77. yp[i] += sty[i];
  78. if (yp[i] > doc_height-50) {
  79. xp[i] = Math.random()*(doc_width-am[i]-30);
  80. yp[i] = 0;
  81. stx[i] = 0.02 + Math.random()/10;
  82. sty[i] = 0.7 + Math.random();
  83. doc_width = document.body.clientWidth;
  84. doc_height = document.body.clientHeight;
  85. }
  86. dx[i] += stx[i];
  87. document.all["dot"+i].style.pixelTop = yp[i];
  88. document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
  89. }
  90. setTimeout("snowIE()", speed);
  91. }
  92. if (ns4up)
  93.  {
  94. snowNS();
  95. }
  96.  else if (ie4up)
  97. {
  98. snowIE();
  99. }
Expand|Select|Wrap|Line Numbers
  1.         </SCRIPT>
  2. </head>
  3. </html>
Davidson

8 March 2008
Mar 8 '08 #1
4 1296
acoder
16,027 Expert Mod 8TB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Mar 8 '08 #2
acoder
16,027 Expert Mod 8TB
Hai Friends,
I have a javascript program , as a snow a single picture will fall from above to below in the browser.It is worked properly when my friend was using.Sudennly it is not working ,pl correct if there is any error and send me.
That is very old code. What doesn't work? In which browser?
Mar 8 '08 #3
davidson1
144 100+
Hai friends it is not working in any browser , pl check and tell me.....sorry for inconvenience..............

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <SCRIPT LANGUAGE="JavaScript">
  4. var no = 25; // snow number
  5. var speed = 10; // smaller number moves the snow faster
  6. //put image in ur computer
  7. var snowflake = "C:\Documents and Settings\Admin\Desktop\jesusinside.gif";
  8. var ns4up = (document.layers) ? 1 : 0; // browser sniffer
  9. var ie4up = (document.all) ? 1 : 0;
  10. var dx, xp, yp; // coordinate and position variables
  11. var am, stx, sty; // amplitude and step variables
  12. var i, doc_width = 800, doc_height = 600;
  13. if (ns4up) {
  14. doc_width = self.innerWidth;
  15. doc_height = self.innerHeight;
  16. } else if (ie4up) {
  17. doc_width = document.body.clientWidth;
  18. doc_height = document.body.clientHeight;
  19. }
  20. dx = new Array();
  21. xp = new Array();
  22. yp = new Array();
  23. am = new Array();
  24. stx = new Array();
  25. sty = new Array();
  26. for (i = 0; i < no; ++ i) {
  27. dx[i] = 0; // set coordinate variables
  28. xp[i] = Math.random()*(doc_width-50); // set position variables
  29. yp[i] = Math.random()*doc_height;
  30. am[i] = Math.random()*20; // set amplitude variables
  31. stx[i] = 0.02 + Math.random()/10; // set step variables
  32. sty[i] = 0.7 + Math.random(); // set step variables
  33. if (ns4up) { // set layers
  34. if (i == 0) {
  35. document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
  36. document.write("top=\"15\" visibility=\"show\"><img src=\"");
  37. document.write(snowflake + "\" border=\"0\"></layer>");
  38. } else {
  39. document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
  40. document.write("top=\"15\" visibility=\"show\"><img src=\"");
  41. document.write(snowflake + "\" border=\"0\"></layer>");
  42. }
  43. else if (ie4up)
  44.  {
  45. if (i == 0)
  46.  {
  47. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
  48. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  49. document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
  50. document.write(snowflake + "\" border=\"0\"></div>");
  51. else 
  52. {
  53. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
  54. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  55. document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
  56. document.write(snowflake + "\" border=\"0\"></div>");
  57. }
  58. }
  59. }
  60. function snowNS() { // Netscape main animation function
  61. for (i = 0; i < no; ++ i) { // iterate for every dot
  62. yp[i] += sty[i];
  63. if (yp[i] > doc_height-50) {
  64. xp[i] = Math.random()*(doc_width-am[i]-30);
  65. yp[i] = 0;
  66. stx[i] = 0.02 + Math.random()/10;
  67. sty[i] = 0.7 + Math.random();
  68. doc_width = self.innerWidth;
  69. doc_height = self.innerHeight;
  70. }
  71. dx[i] += stx[i];
  72. document.layers["dot"+i].top = yp[i];
  73. document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
  74. }
  75. setTimeout("snowNS()", speed);
  76. }
  77. function snowIE() { // IE main animation function
  78. for (i = 0; i < no; ++ i) { // iterate for every dot
  79. yp[i] += sty[i];
  80. if (yp[i] > doc_height-50) {
  81. xp[i] = Math.random()*(doc_width-am[i]-30);
  82. yp[i] = 0;
  83. stx[i] = 0.02 + Math.random()/10;
  84. sty[i] = 0.7 + Math.random();
  85. doc_width = document.body.clientWidth;
  86. doc_height = document.body.clientHeight;
  87. }
  88. dx[i] += stx[i];
  89. document.all["dot"+i].style.pixelTop = yp[i];
  90. document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
  91. }
  92. setTimeout("snowIE()", speed);
  93. }
  94. if (ns4up)
  95.  {
  96. snowNS();
  97. }
  98.  else if (ie4up)
  99. {
  100. snowIE();
  101. }
  102. </SCRIPT>
  103. </HEAD>
  104. </html>
  105.  

Davidson
9 March 2008
Mar 9 '08 #4
acoder
16,027 Expert Mod 8TB
Nice try with the code tags. Unfortunately, you used <code> instead of [code]. The code tags are enclosed using square brackets.
Hai friends it is not working in any browser , pl check and tell me.....sorry for inconvenience.
What errors do you see? Check the error console.

As I said, this is old code. If you've not written this, I would suggest finding a newer version that works in modern browsers.
Mar 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Axel Foley | last post by:
Hi Folks, i'm newbie at JS; but "learning by tweaking" is my middle name! Trying to set up a link partnership application on a client's site; got this script at "The Javascript Source", but it...
1
by: vncntj | last post by:
i want to enable one listbox and disable the other depending on if i check winter_gala (checkbox) here is my code. <script type="text/javascript"> function check() { if...
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.