Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 29.12.2014, 18:45
Новичок на форуме
Отправить личное сообщение для se4a Посмотреть профиль Найти все сообщения от se4a
 
Регистрация: 28.12.2014
Сообщений: 2

Помогите, пожалуйста, с "подстройкой" скрипта под GOOGLE Chrome, FireFox, Opera и пр.
Приветствую всех!
Обращается к Вам Сергей Коршунов.
Я - инвалид детства, ДЦП. Из-за своего заболевания сидел дома без дела.
В начале лета сосед попросил "администрировать" его сайт. В середине декабра
хотел установит "снег" не сайт. В сети нашёл скрипт :

<script language="JavaScript1.2"><!-- Begin 
 ///////////////////////////////////////////////// 
 //Автор Скрипта - Федор А. Нохрин aka FANTAzeRus/ 
 ///////////////////////////////////////////////// 
  
 var no = 15; // колличество снежинок 
var speed =25; // скорость снежинок 
var snowflake = "http://www.sbor.net/~fantazer/fanta/sneg.gif"; 
  
 var ns4up = (document.layers) ? 1 : 0; 
 var ie4up = (document.all) ? 1 : 0; 
 var dx, xp, yp;  
 var am, stx, sty;  
 var i, doc_width = 800, doc_height = 600; 
  
 if (ns4up) 
  { 
   doc_width = self.innerWidth; 
   doc_height = self.innerHeight; 
  } 
 else if (ie4up) 
  { 
   doc_width = document.body.clientWidth; 
   doc_height = document.body.clientHeight; 
  } 
  
 dx = new Array(); 
 xp = new Array(); 
 yp = new Array(); 
 am = new Array(); 
 stx = new Array(); 
 sty = new Array(); 
  
 for (i = 0; i < no; ++ i) 
  {   
   dx[i] = 0;          
   xp[i] = Math.random()*(doc_width-50);  
   yp[i] = Math.random()*doc_height; 
   am[i] = Math.random()*20;          
   stx[i] = 0.02 + Math.random()/10;  
   sty[i] = 0.7 + Math.random();    
   if (ns4up) 
    {                   
     if (i == 0) 
      { 
       document.write("<layer name=\"dot"+ i +"\" left=\"15\" "); 
       document.write("top=\"15\" visibility=\"show\"><img src=\""); 
       document.write(snowflake + "\" border=\"0\"></layer>"); 
      } 
     else 
      { 
       document.write("<layer name=\"dot"+ i +"\" left=\"15\" "); 
       document.write("top=\"15\" visibility=\"show\"><img src=\""); 
       document.write(snowflake + "\" border=\"0\"></layer>"); 
      } 
    } 
   else if (ie4up) 
    { 
     if (i == 0) 
      { 
       document.write("<div id=\"dot"+ i +"\" style=\"POSITION: "); 
       document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: "); 
       document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\""); 
       document.write(snowflake + "\" border=\"0\"></div>"); 
      } 
     else 
      { 
       document.write("<div id=\"dot"+ i +"\" style=\"POSITION: "); 
       document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: "); 
       document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\""); 
       document.write(snowflake + "\" border=\"0\"></div>"); 
      } 
    } 
  } 
  
 function snowNS() 
  {  
   for (i = 0; i < no; ++ i) 
    {   
     yp[i] += sty[i]; 
     if (yp[i] > doc_height-50) 
      { 
       xp[i] = Math.random()*(doc_width-am[i]-30); 
       yp[i] = 0; 
       stx[i] = 0.02 + Math.random()/10; 
       sty[i] = 0.7 + Math.random(); 
       doc_width = self.innerWidth; 
       doc_height = self.innerHeight; 
      } 
     dx[i] += stx[i]; 
     document.layers["dot"+i].top = yp[i]; 
     document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]); 
    } 
   setTimeout("snowNS()", speed); 
  } 
  
 function snowIE() 
  {  
   for (i = 0; i < no; ++ i) 
    {  
     yp[i] += sty[i]; 
     if (yp[i] > doc_height-50) 
      { 
       xp[i] = Math.random()*(doc_width-am[i]-30); 
       yp[i] = 0; 
       stx[i] = 0.02 + Math.random()/10; 
       sty[i] = 0.7 + Math.random(); 
       doc_width = document.body.clientWidth; 
       doc_height = document.body.clientHeight; 
      } 
     dx[i] += stx[i]; 
     document.all["dot"+i].style.pixelTop = yp[i]; 
     document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]); 
    } 
   setTimeout("snowIE()", speed); 
  } 
  
 if (ns4up) 
  { 
   snowNS(); 
  } 
 else if (ie4up) 
  { 
   snowIE(); 
  } 
  
 // End --> 
 </script>


Подскажите, пожалуйста, что нужно прописать в :

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


Чтобы скрипт "заработал" в GOOGLE Chrome, FireDox, Opera и прочих ?

С уважением, Сергей.

Последний раз редактировалось se4a, 29.12.2014 в 18:48. Причина: Орфографические ошибки
Ответить с цитированием
  #2 (permalink)  
Старый 30.12.2014, 21:56
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,103

se4a, снежок
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <style type="text/css">
  body{
    background-color: rgb(0, 255, 255);
  }

  </style>
</head>

<body>
<script>
 /////////////////////////////////////////////////
 //Автор Скрипта - Федор А. Нохрин aka FANTAzeRus/
 /////////////////////////////////////////////////

 var no = 15; // колличество снежинок
var speed =25; // скорость снежинок
var snowflake = "http://www.sbor.net/~fantazer/fanta/sneg.gif";

 var ns4up =  0;
 var ie4up = 1
 var dx, xp, yp;
 var am, stx, sty;
 var i, doc_width = 800, doc_height = 600;
 doc_width = document.documentElement.scrollWidth;
 doc_height = Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight);



 dx = new Array();
 xp = new Array();
 yp = new Array();
 am = new Array();
 stx = new Array();
 sty = new Array();

 for (i = 0; i < no; ++ i)
  {
   dx[i] = 0;
   xp[i] = Math.random()*(doc_width-50);
   yp[i] = Math.random()*doc_height;
   am[i] = Math.random()*20;
   stx[i] = 0.02 + Math.random()/10;
   sty[i] = 0.7 + Math.random();

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





 function snowIE()
  {
   for (i = 0; i < no; ++ i)
    {
     yp[i] += sty[i];
     if (yp[i] > doc_height-50)
      {
       xp[i] = Math.random()*(doc_width-am[i]-30);
       yp[i] = 0;
       stx[i] = 0.02 + Math.random()/10;
       sty[i] = 0.7 + Math.random();
       doc_width = document.documentElement.scrollWidth;
       doc_height = Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight);
      }
     dx[i] += stx[i];

    document.getElementById("dot"+i).style.top = yp[i]+"px";
    document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i])+"px";
    }
   setTimeout("snowIE()", speed);
  }

   snowIE();



 </script>

</body>

</html>

Последний раз редактировалось рони, 30.12.2014 в 22:01.
Ответить с цитированием
  #3 (permalink)  
Старый 30.12.2014, 23:17
Аватар для bes
bes bes вне форума
Профессор
Отправить личное сообщение для bes Посмотреть профиль Найти все сообщения от bes
 
Регистрация: 22.03.2012
Сообщений: 3,744

ой, ещё один
<style>
body {
	background: url(http://img-kiev.fotki.yandex.ru/get/6004/sockolovanatascha.5c/0_5a2f4_589aadc0_XL.gif) no-repeat center center fixed;
	background-size: cover;
}
pre {
	color: yellow;
	text-align: center;
}
</style>
<body>
<pre>
Jingle Bells

Dashing through the snow
In a one-horse open sleigh
O’er the fields we go
Laughing all the way
Bells on bobtail ring
Making spirits bright
What fun it is to laugh and sing
A sleighing song tonight!

Chorus:
Jingle bells, jingle bells,
Jingle all the way.
Oh! what fun it is to ride
In a one-horse open sleigh.
Jingle bells, jingle bells,
Jingle all the way;
Oh! what fun it is to ride
In a one-horse open sleigh.

A day or two ago
I thought I’d take a ride
And soon, Miss Fanny Bright
Was seated by my side,
The horse was lean and lank
Misfortune seemed his lot
He got into a drifted bank
And then we got upset.

Chorus

A day or two ago,
The story I must tell
I went out on the snow,
And on my back I fell;
A gent was riding by
In a one-horse open sleigh,
He laughed as there I sprawling lie,
But quickly drove away.

Chorus

Now the ground is white
Go it while you’re young,
Take the girls tonight
and sing this sleighing song;
Just get a bobtailed bay
Two forty as his speed
Hitch him to an open sleigh
And crack! you’ll take the lead.

Chorus
</pre>
Ответить с цитированием
  #4 (permalink)  
Старый 30.12.2014, 23:18
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,103

bes,
Ответить с цитированием
  #5 (permalink)  
Старый 01.01.2015, 18:39
Новичок на форуме
Отправить личное сообщение для se4a Посмотреть профиль Найти все сообщения от se4a
 
Регистрация: 28.12.2014
Сообщений: 2

Благодарю всех за посильную помощь!
Особая благодарность - рони!
Всех с Новым 2015-ым и всех благ!
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
тег <audio> в Opera, Chrome, Firefox Magneto Javascript под браузер 12 25.11.2010 15:12
innerHTML под Chrome, IE7 KillaBee Events/DOM/Window 3 21.08.2010 17:28
FireFox не видет скрипта помогите пожалуйста KuzmenkoArtem Firefox/Mozilla 9 05.07.2010 02:56
Помогите пожалуйста новичку. deepslam jQuery 15 26.07.2009 02:21
Люди, помогите адаптировать скрипт под Оперу KiLLk Opera, Safari и др. 1 01.06.2009 01:05