Java

         

Графические часы


Первый пример - это часы, отображающие время загрузки страницы (т.е. момент вызова скрипта). Используются методы объекта Date (getHours, getMinutes) и графические файлы, отображающие полученное время (имена этих файлов соответствуют цифрам - 0-9).

Во втором примере, отображающем текущую дату, также используются методы объекта Date (getDate, getMnth, getYear) и графические файлы, отображающие полученную дату (имена этих файлов соответствуют цифрам - 0-9).

1.<SCRIPT LANGUAGE="JavaScript">

<!--

// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.

// Permission given to use the script provided that this notice remains as is.

// Additional scripts can be found at http:

//www.geocities.com/~yehuda

/// image files needed:

// dg0.gif

// dg1.gif

// dg2.gif

// dg3.gif

// dg4.gif

// dg5.gif

// dg6.gif

// dg7.gif

// dg8.gif

// dg9.gif

// dgam.gif

// dgpm.gif

// dgc.gif

// Any set of digit images (0-9), an "am" image,

// a "pm" image, and a colon image respectively

// will work with this script.

// instructions:

// Place all image files in a folder / directory.

// Add this script, including all comments, to

// the desired HTML document. The HTML file must

// be located in the same directory as the image

// files.

document.write(setClock())

function setClock() {

// initialize accumulative HTML variable to empty string

var text = ""

// set standard convention for digit and punctuation images

var openImage = "<IMG SRC=\"" + getPath(location.href) + "dg"

var closeImage = ".gif\" HEIGHT=21 WIDTH=16>"

// initialize time-related variables with current time settings

var now = new Date()

var hour = now.getHours()

var minute = now.getMinutes()

now = null

var ampm = ""

// validate hour values

and set value of ampm

if (hour >= 12) {

hour -= 12

ampm = "pm"

} else

ampm = "am"

hour = (hour == 0) ? 12 : hour



Содержание  Назад  Вперед







Forekc.ru
Рефераты, дипломы, курсовые, выпускные и квалификационные работы, диссертации, учебники, учебные пособия, лекции, методические пособия и рекомендации, программы и курсы обучения, публикации из профильных изданий