php, java
статьи, книги
рефераты, ГДЗ

Бесплатные ключи и сброс
пробной версии для Касперского

Все для cs 1.6

Самые лучшие сеты моделей и избранные подборки девушек

Четверг, 25 Апр 2024, 07:13:33

Приветствую Вас Гость | RSS
Главная | Каталог файлов | Регистрация | Вход
Меню сайта

ФИЗИКА!!! NEW!!!

Русский!!! NEW!!!

Категории раздела
Javascript окна [17]
Javascript окна
Заполнение форм [21]
Заполнение форм
Защита от копирования [4]
Защита от копирования
Игры [9]
Игры
Использование заголовка окна [4]
Использование заголовка окна
Использование строки статуса [12]
Использование строки статуса
Календари и часы [52]
Календари и часы
Кнопки [10]
Кнопки
Надписи [11]
Надписи
Полезное для сайта [21]
Небольшие скрипты (печать, браузеры, избраное, css и д.р.)
Поиск [3]
Поиск

Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0

Главная » Файлы » java скрипты » Использование строки статуса

Вылетающие сообщение в строке статуса
[ ] 31 Июл 2007, 09:36:03
<html>
<head>
<title>Вылетающие сообщения в строке статуса</title>
<script language="JavaScript" type="text/javascript">
<!--
// set speed of banner (pause in milliseconds between addition of new character)
var speed = 5 // decrease value to increase speed (must be positive)
// set pause between completion of message and beginning of following message
var pause = 1500 // increase value to increase pause
// set initial values
var timerID = null
var bannerRunning = false
// create array
var ar = new Array()
// assign the strings to the array's elements
ar[0] = "Добро пожаловать"
ar[1] = "Меня зовут Лидия"
// assign index of current message
var message = 0
// empty string initialization
var state = ""
// no value is currently being displayed
clearState()
// stop the banner if it is currently running
function stopBanner() {
 // if banner is currently running
 if (bannerRunning)
  // stop the banner
  clearTimeout(timerID)
 // banner is now stopped
 bannerRunning = false
}
// start the banner
function startBanner() {
 // make sure the banner is stopped
 stopBanner()
 // start the banner from the current position
 showBanner()
}
// assign state a string of "0" characters of the length of the current message
function clearState() {
 // initialize to empty string
 state = ""
 // create string of same length containing 0 digits
 for (var i = 0; i < ar[message].length; ++i) {
  state += "0"
 }
}
// display the current message
function showBanner() {
 // if the current message is done
 if (getString()) {
  // increment message
  message++
  // if new message is out of range wrap around to first message
  if (ar.length <= message)
   message = 0
  // new message is first displayed as empty string
  clearState()
  // display next character after pause milliseconds
  timerID = setTimeout("showBanner()", pause)
  // banner is now running
  bannerRunning = true
 } else {
  // initialize to empty string
  var str = ""
  // built string to be displayed (only character selected thus far are displayed)
  for (var j = 0; j < state.length; ++j) {
   str += (state.charAt(j) == "1") ? ar[message].charAt(j) : "     "
  }
  // partial string is placed in status bar
  window.status = str
  // add another character after speed milliseconds
  timerID = setTimeout("showBanner()", speed)
  // banner is now running
  bannerRunning = true
 }
}
function getString() {
 // set variable to true (it will stay true unless proven otherwise)
 var full = true
 // set variable to false if a free space is found in string (a not-displayed char)
 for (var j = 0; j < state.length; ++j) {
  // if character at index j of current message has not been placed in displayed string
  if (state.charAt(j) == 0)
   full = false
 }
 // return true immediately if no space found (avoid infinitive loop later)
 if (full)
  return true
 // search for random until free space found (braoken up via break statement)
 while (1) {
  // a random number (between 0 and state.length - 1 == message.length - 1)
  var num = getRandom(ar[message].length)
  // if free space found break infinitive loop
  if (state.charAt(num) == "0")
   break
 }
 // replace the 0 character with 1 character at place found
 state = state.substring(0, num) + "1" + state.substring(num + 1, state.length)
 // return false because the string was not full (free space was found)
 return false
}
function getRandom(max) {
 return Math.round((max - 1) * Math.random())
}
// -->
</script>
 </head>
<body onLoad="startBanner()">
</body>
</html>
Категория: Использование строки статуса | Добавил: ceg
Просмотров: 423 | Загрузок: 0 | Рейтинг: 0.0/0 |
Всего комментариев: 0
Имя *:
Email *:
Код *:
Форма входа

Реклама

Поиск

Друзья сайта
  • Играете в Counter-Strike??? ВАМ СЮДА!!!

  • Copyright CEG © 2024