Clique abaixo para nos ajudar
Conectar-se

Esqueci minha senha

Estamos no Facebook
Buscar
 
 

Resultados por:
 


Rechercher Busca avançada

Quem está conectado
3 usuários online :: Nenhum usuário registrado, Nenhum Invisível e 3 Visitantes :: 1 Motor de busca

Nenhum

[ Ver toda a lista ]


O recorde de usuários online foi de 468 em 1/3/2012, 10:43
COMO ESTÃO DESENVOLVENDO EM WEB?

22/8/2016, 10:48 por AJC

Pessoal, já lí sobre vários topicos aqui no forum sobre desenvolvimento web
mas ainda nada …

Comentários: 3

TRY BEGIN E FLOCK()

17/4/2017, 10:32 por AJC

Pessoal estou tendo alguns problemas de gravação em rede, estou usando
try begin, mas vi algo na …

Comentários: 1

DESENVOLVIMENTO EM REDES

4/3/2017, 18:45 por AJC

Pessoal tem ou conhece livros ou material para programação em
redes usando banco de dados nativo …

Comentários: 1

ACESSAR WEBSERVICE COM HTTPS

5/4/2018, 14:48 por AJC

Pessoal recebi este material em C# preciso fazer esta função em vfp9

YourBeanService port = new …

Comentários: 0

REPORT FORM - GERAR 2 RELATORIOS

18/3/2018, 19:02 por AJC

Pessoal, estou tentando gerar dois tipos de relatorio no report form
ou seja
primeira folha - …

Comentários: 2

Estatísticas
Temos 7095 usuários registrados
O último usuário registrado atende pelo nome de Robson0

Os nossos membros postaram um total de 12260 mensagens em 1554 assuntos

JavaScript para HTML

Ir em baixo

Resolvido JavaScript para HTML

Mensagem por paula91 em 23/2/2011, 17:10

Ola,

Precisava de uma ajuda... Estou tipo a configurar um site e quero colocar um javascript no código html...

O código é este:

Aqui coloco entre <head></head>


Código:
    * Home
    * Code
    * Learn

World Clock
Example
GMT   Vancouver   San Francisco   Seattle
February 23, 2011
20:04:13   February 23, 2011
12:04:13   February 23, 2011
12:04:13   February 23, 2011
12:04:13
Los Angeles   Denver   Mexico City   Houston
February 23, 2011
12:04:13   February 23, 2011
13:04:13   February 23, 2011
14:04:13   February 23, 2011
14:04:13
Minneapolis   New Orleans   Chicago   Montgomery
February 23, 2011
14:04:13   February 23, 2011
14:04:13   February 23, 2011
14:04:13   February 23, 2011
14:04:13
Indianapolis   Atlanta   Detroit   Miami
February 23, 2011
15:04:13   February 23, 2011
15:04:13   February 23, 2011
15:04:13   February 23, 2011
15:04:13
Washington DC   Philadelphia   New York   Montreal
February 23, 2011
15:04:13   February 23, 2011
15:04:13   February 23, 2011
15:04:13   February 23, 2011
15:04:13
Boston   Buenos Aires   Sao Paulo   Rio De Janeiro
February 23, 2011
15:04:13   February 23, 2011
17:04:13   February 23, 2011
17:04:13   February 23, 2011
17:04:13
Lisbon   Dublin   London   Madrid
February 23, 2011
20:04:13   February 23, 2011
20:04:13   February 23, 2011
20:04:13   February 23, 2011
21:04:13
Barcelona   Paris   Brussels   Amsterdam
February 23, 2011
21:04:13   February 23, 2011
21:04:13   February 23, 2011
21:04:13   February 23, 2011
21:04:13
Frankfurt   Rome   Berlin   Prague
February 23, 2011
21:04:13   February 23, 2011
21:04:13   February 23, 2011
21:04:13   February 23, 2011
21:04:13
Vienna   Stockholm   Athens   Helsinki
February 23, 2011
21:04:13   February 23, 2011
21:04:13   February 23, 2011
22:04:13   February 23, 2011
22:04:13
Minsk   Istanbul   Cairo   Jerusalem
February 23, 2011
22:04:13   February 23, 2011
22:04:13   February 23, 2011
22:04:13   February 23, 2011
22:04:13
Beirut   Moscow   Baghdad   Dubai
February 23, 2011
22:04:13   February 23, 2011
23:04:13   February 23, 2011
23:04:13   February 24, 2011
0:04:13
Bangkok   Jakarta   Hong Kong   Beijing
February 24, 2011
3:04:13   February 24, 2011
3:04:13   February 24, 2011
4:04:13   February 24, 2011
4:04:13
Shanghai   Seoul   Tokyo   Melbourne
February 24, 2011
4:04:13   February 24, 2011
5:04:13   February 24, 2011
5:04:13   February 24, 2011
7:04:13 DST
Sydney   Brisbane   Vladivostok   Kamchatka
February 24, 2011
7:04:13 DST   February 24, 2011
6:04:13   February 24, 2011
6:04:13   February 24, 2011
8:04:13
Code
Put this in the head part of the document

<script language="JavaScript">
<!--
function worldClock(zone, region){
var dst = 0
var time = new Date()
var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
var gmtTime = new Date(gmtMS)
var day = gmtTime.getDate()
var month = gmtTime.getMonth()
var year = gmtTime.getYear()
if(year < 1000){
year += 1900
}
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August",
            "September", "October", "November", "December")
var monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
if (year%4 == 0){
monthDays = new Array("31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}
if(year%100 == 0 && year%400 != 0){
monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}

var hr = gmtTime.getHours() + zone
var min = gmtTime.getMinutes()
var sec = gmtTime.getSeconds()

if (hr >= 24){
hr = hr-24
day -= -1
}
if (hr < 0){
hr -= -24
day -= 1
}
if (hr < 10){
hr = " " + hr
}
if (min < 10){
min = "0" + min
}
if (sec < 10){
sec = "0" + sec
}
if (day <= 0){
if (month == 0){
   month = 11
   year -= 1
   }
   else{
   month = month -1
   }
day = monthDays[month]
}
if(day > monthDays[month]){
   day = 1
   if(month == 11){
   month = 0
   year -= -1
   }
   else{
   month -= -1
   }
}
if (region == "NAmerica"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(2)
   startDST.setDate(1)
   var dayDST = startDST.getDay()
   if (dayDST != 0){
      startDST.setDate(8-dayDST)
      }
      else{
      startDST.setDate(1)
      }
   endDST.setMonth(9)
   endDST.setHours(1)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Europe"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(2)
   startDST.setHours(1)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(9)
   endDST.setHours(0)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}

if (region == "SAmerica"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(9)
   startDST.setHours(0)
   startDST.setDate(1)
   var dayDST = startDST.getDay()
   if (dayDST != 0){
      startDST.setDate(22-dayDST)
      }
      else{
      startDST.setDate(15)
      }
   endDST.setMonth(1)
   endDST.setHours(11)
   endDST.setDate(1)
   dayDST = endDST.getDay()
   if (dayDST != 0){
      endDST.setDate(21-dayDST)
      }
      else{
      endDST.setDate(14)
      }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST || currentTime < endDST){
      dst = 1
      }
}
if (region == "Cairo"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(0)
   startDST.setDate(30)
   var dayDST = startDST.getDay()
   if (dayDST < 5){
      startDST.setDate(28-dayDST)
      }
      else {
      startDST.setDate(35-dayDST)
      }
   endDST.setMonth(8)
   endDST.setHours(11)
   endDST.setDate(30)
   dayDST = endDST.getDay()
   if (dayDST < 4){
      endDST.setDate(27-dayDST)
      }
      else{
      endDST.setDate(34-dayDST)
      }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Israel"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(2)
   startDST.setDate(1)
   endDST.setMonth(8)
   endDST.setHours(2)
   endDST.setDate(25)
   dayDST = endDST.getDay()
   if (dayDST != 0){
   endDST.setDate(32-dayDST)
   }
   else{
   endDST.setDate(1)
   endDST.setMonth(9)
   }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Beirut"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(2)
   startDST.setHours(0)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(9)
   endDST.setHours(11)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(30-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Baghdad"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(3)
   startDST.setDate(1)
   endDST.setMonth(9)
   endDST.setHours(3)
   endDST.setDate(1)
   dayDST = endDST.getDay()
      var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Australia"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(9)
   startDST.setHours(2)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(2)
   endDST.setHours(2)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST || currentTime < endDST){
      dst = 1
      }
}

   
if (dst == 1){
   hr -= -1
   if (hr >= 24){
   hr = hr-24
   day -= -1
   }
   if (hr < 10){
   hr = " " + hr
   }
   if(day > monthDays[month]){
   day = 1
   if(month == 11){
   month = 0
   year -= -1
   }
   else{
   month -= -1
   }
   }
return monthArray[month] + " " + day + ", " + year + "<br>" + hr + ":" + min + ":" + sec + " DST"
}
else{
return monthArray[month] + " " + day + ", " + year + "<br>" + hr + ":" + min + ":" + sec
}
}

function worldClockZone(){
document.getElementById("GMT").innerHTML = worldClock(0, "Greenwich")
document.getElementById("Vancouver").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("SanFrancisco").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("Seattle").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("LosAngeles").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("Denver").innerHTML = worldClock(-7, "NAmerica")
document.getElementById("MexicoCity").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Houston").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Minneapolis").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("NewOrleans").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Chicago").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Montgomery").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Indianapolis").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Atlanta").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Detroit").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Miami").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("WashingtonDC").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Philadelphia").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("NewYork").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Montreal").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Boston").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("BuenosAires").innerHTML = worldClock(-3, "BuenosAires")
document.getElementById("SaoPaulo").innerHTML = worldClock(-3, "SAmerica")
document.getElementById("RioDeJaneiro").innerHTML = worldClock(-3, "SAmerica")
document.getElementById("Lisbon").innerHTML = worldClock(0, "Europe")
document.getElementById("Dublin").innerHTML = worldClock(0, "Europe")
document.getElementById("London").innerHTML = worldClock(0, "Europe")
document.getElementById("Madrid").innerHTML = worldClock(1, "Europe")
document.getElementById("Barcelona").innerHTML = worldClock(1, "Europe")
document.getElementById("Paris").innerHTML = worldClock(1, "Europe")
document.getElementById("Brussels").innerHTML = worldClock(1, "Europe")
document.getElementById("Amsterdam").innerHTML = worldClock(1, "Europe")
document.getElementById("Frankfurt").innerHTML = worldClock(1, "Europe")
document.getElementById("Rome").innerHTML = worldClock(1, "Europe")
document.getElementById("Berlin").innerHTML = worldClock(1, "Europe")
document.getElementById("Prague").innerHTML = worldClock(1, "Europe")
document.getElementById("Vienna").innerHTML = worldClock(1, "Europe")
document.getElementById("Stockholm").innerHTML = worldClock(1, "Europe")
document.getElementById("Athens").innerHTML = worldClock(2, "Europe")
document.getElementById("Helsinki").innerHTML = worldClock(2, "Europe")
document.getElementById("Minsk").innerHTML = worldClock(2, "Europe")
document.getElementById("Istanbul").innerHTML = worldClock(2, "Europe")
document.getElementById("Cairo").innerHTML = worldClock(2, "Cairo")
document.getElementById("Jerusalem").innerHTML = worldClock(2, "Israel")
document.getElementById("Beirut").innerHTML = worldClock(2, "Beirut")
document.getElementById("Moscow").innerHTML = worldClock(3, "Europe")
document.getElementById("Baghdad").innerHTML = worldClock(3, "Baghdad")
document.getElementById("Dubai").innerHTML = worldClock(4, "Dubai")
document.getElementById("Bangkok").innerHTML = worldClock(7, "Bangkok")
document.getElementById("Jakarta").innerHTML = worldClock(7, "Jakarta")
document.getElementById("HongKong").innerHTML = worldClock(8, "HongKong")
document.getElementById("Beijing").innerHTML = worldClock(8, "Beijing")
document.getElementById("Shanghai").innerHTML = worldClock(8, "Shanghai")
document.getElementById("Seoul").innerHTML = worldClock(9, "Seoul")
document.getElementById("Tokyo").innerHTML = worldClock(9, "Tokyo")
document.getElementById("Melbourne").innerHTML = worldClock(10, "Australia")
document.getElementById("Sydney").innerHTML = worldClock(10, "Australia")
document.getElementById("Brisbane").innerHTML = worldClock(10, "Brisbane")
document.getElementById("Vladivostok").innerHTML = worldClock(10, "Europe")
document.getElementById("Kamchatka").innerHTML = worldClock(12, "Europe")

setTimeout("worldClockZone()", 1000)
}
window.onload=worldClockZone;

//-->
</script>

<style type="text/css">
.hrow {
font-weight:bold;
color: #C1E97C;
}
.hrow td{
padding-top: 20px;
width: 140px;
}
</style>

Put this in the body part of the document

<table cellspacing="5px">
<tr class="hrow">
<td>GMT</td><td>Vancouver</td><td>San Francisco</td><td>Seattle</td>
</tr>
<tr>
<td><span id="GMT"></span></td><td><span id="Vancouver"></span></td><td><span id="SanFrancisco"></span></td><td><span id="Seattle"></span></td>
</tr>
<tr class="hrow">
<td>Los Angeles</td><td>Denver</td><td>Mexico City</td><td>Houston</td>
</tr>
<tr>
<td><span id="LosAngeles"></span></td><td><span id="Denver"></span></td><td><span id="MexicoCity"></span></td><td><span id="Houston"></span></td>
</tr>
<tr class="hrow">
<td>Minneapolis</td><td>New Orleans</td><td>Chicago</td><td>Montgomery</td>
</tr>
<tr>
<td><span id="Minneapolis"></span></td><td><span id="NewOrleans"></span></td><td><span id="Chicago"></span></td><td><span id="Montgomery"></span></td>
</tr>
<tr class="hrow">
<td>Indianapolis</td><td>Atlanta</td><td>Detroit</td><td>Miami</td>
</tr>
<tr>
<td><span id="Indianapolis"></span></td><td><span id="Atlanta"></span></td><td><span id="Detroit"></span></td><td><span id="Miami"></span></td>
</tr>
<tr class="hrow">
<td>Washington DC</td><td>Philadelphia</td><td>New York</td><td>Montreal</td>
</tr>
<tr>
<td><span id="WashingtonDC"></span></td><td><span id="Philadelphia"></span></td><td><span id="NewYork"></span></td><td><span id="Montreal"></span></td>
</tr>
<tr class="hrow">
<td>Boston</td><td>Buenos Aires</td><td>Sao Paulo</td><td>Rio De Janeiro</td>
</tr>
<tr>
<td><span id="Boston"></span></td><td><span id="BuenosAires"></span></td><td><span id="SaoPaulo"></span></td><td><span id="RioDeJaneiro"></span></td>
</tr>
<tr class="hrow">
<td>Lisbon</td><td>Dublin</td><td>London</td><td>Madrid</td>
</tr>
<tr>
<td><span id="Lisbon"></span></td><td><span id="Dublin"></span></td><td><span id="London"></span></td><td><span id="Madrid"></span></td>
</tr>
<tr class="hrow">
<td>Barcelona</td><td>Paris</td><td>Brussels</td><td>Amsterdam</td>
</tr>
<tr>
<td><span id="Barcelona"></span></td><td><span id="Paris"></span></td><td><span id="Brussels"></span></td><td><span id="Amsterdam"></span></td>
</tr>
<tr class="hrow">
<td>Frankfurt</td><td>Rome</td><td>Berlin</td><td>Prague</td>
</tr>
<tr>
<td><span id="Frankfurt"></span></td><td><span id="Rome"></span></td><td><span id="Berlin"></span></td><td><span id="Prague"></span></td>
</tr>
<tr class="hrow">
<td>Vienna</td><td>Stockholm</td><td>Athens</td><td>Helsinki</td>
</tr>
<tr>
<td><span id="Vienna"></span></td><td><span id="Stockholm"></span></td><td><span id="Athens"></span></td><td><span id="Helsinki"></span></td>
</tr>
<tr class="hrow">
<td>Minsk</td><td>Istanbul</td><td>Cairo</td><td>Jerusalem</td>
</tr>
<tr>
<td><span id="Minsk"></span></td><td><span id="Istanbul"></span></td><td><span id="Cairo"></span></td><td><span id="Jerusalem"></span></td>
</tr>
<tr class="hrow">
<td>Beirut</td><td>Moscow</td><td>Baghdad</td><td>Dubai</td>
</tr>
<tr>
<td><span id="Beirut"></span></td><td><span id="Moscow"></span></td><td><span id="Baghdad"></span></td><td><span id="Dubai"></span></td>
</tr>
<tr class="hrow">
<td>Bangkok</td><td>Jakarta</td><td>Hong Kong</td><td>Beijing</td>
</tr>
<tr>
<td><span id="Bangkok"></span></td><td><span id="Jakarta"></span></td><td><span id="HongKong"></span></td><td><span id="Beijing"></span></td>
</tr>
<tr class="hrow">
<td>Shanghai</td><td>Seoul</td><td>Tokyo</td><td>Melbourne</td>
</tr>
<tr>
<td><span id="Shanghai"></span></td><td><span id="Seoul"></span></td><td><span id="Tokyo"></span></td><td><span id="Melbourne"></span></td>
</tr>
<tr class="hrow">
<td>Sydney</td><td>Brisbane</td><td>Vladivostok</td><td>Kamchatka</td>
</tr>
<tr>
<td><span id="Sydney"></span></td><td><span id="Brisbane"></span></td><td><span id="Vladivostok"></span></td><td><span id="Kamchatka"></span></td>
</tr>
</table>

    * JavaScript
    * Java

Newest Code

    * Java: Sort Algorithms Library (May 24)
    * Java: Quick Sort (May 24)
    * Java: Merge Sort (May 24)
    * Java: Shell Sort (May 24)
    * Java: Insertion Sort (May 24)
    * Java: Selection Sort (May 24)
    * Java: Bubble Sort (May 24)
    * Java: Font Viewer (May 08)
    * Javascript: Time Left Until... (Mar 15)
    * Javascript: Countdown (Mar 12)

View all code
Newest Lessons

    * javascript: Pop-up Windows (Dec 11)
    * javascript: Cookies (Dec 11)
    * javascript: The Image Object (Dec 11)
    * javascript: The Object Hier... (Dec 11)
    * javascript: Loops, Noscript... (Dec 11)
    * javascript: Use of The Date... (Dec 11)
    * javascript: Arrays and The ... (Dec 11)
    * javascript: Objects and The... (Dec 11)
    * javascript: Forms, Dialog B... (Dec 11)
    * javascript: If Statement, B... (Dec 11)

View all lessons
Most Popular Code

    * Javascript: World Clock (23858)
    * Java: Towers Of Hanoi (19966)
    * Java: Roll Dice (10956)

Most Popular Lessons

    * javascript: The Image Object (12339)
    * javascript: Objects and The... (4939)
    * javascript: Use of The Date... (3976)

Home | Code | Learn
©️ 2007-2008 ProgLogic, all rights reserved. | ProgLogic.com is created by Stijn Strickx. | e-mail

E depois aqui coloco <body></body>

Código:

    * Home
    * Code
    * Learn

World Clock
Example
GMT   Vancouver   San Francisco   Seattle
February 23, 2011
20:06:15   February 23, 2011
12:06:15   February 23, 2011
12:06:15   February 23, 2011
12:06:15
Los Angeles   Denver   Mexico City   Houston
February 23, 2011
12:06:15   February 23, 2011
13:06:15   February 23, 2011
14:06:15   February 23, 2011
14:06:15
Minneapolis   New Orleans   Chicago   Montgomery
February 23, 2011
14:06:15   February 23, 2011
14:06:15   February 23, 2011
14:06:15   February 23, 2011
14:06:15
Indianapolis   Atlanta   Detroit   Miami
February 23, 2011
15:06:15   February 23, 2011
15:06:15   February 23, 2011
15:06:15   February 23, 2011
15:06:15
Washington DC   Philadelphia   New York   Montreal
February 23, 2011
15:06:15   February 23, 2011
15:06:15   February 23, 2011
15:06:15   February 23, 2011
15:06:15
Boston   Buenos Aires   Sao Paulo   Rio De Janeiro
February 23, 2011
15:06:15   February 23, 2011
17:06:15   February 23, 2011
17:06:15   February 23, 2011
17:06:15
Lisbon   Dublin   London   Madrid
February 23, 2011
20:06:15   February 23, 2011
20:06:15   February 23, 2011
20:06:15   February 23, 2011
21:06:15
Barcelona   Paris   Brussels   Amsterdam
February 23, 2011
21:06:15   February 23, 2011
21:06:15   February 23, 2011
21:06:15   February 23, 2011
21:06:15
Frankfurt   Rome   Berlin   Prague
February 23, 2011
21:06:15   February 23, 2011
21:06:15   February 23, 2011
21:06:15   February 23, 2011
21:06:15
Vienna   Stockholm   Athens   Helsinki
February 23, 2011
21:06:15   February 23, 2011
21:06:15   February 23, 2011
22:06:15   February 23, 2011
22:06:15
Minsk   Istanbul   Cairo   Jerusalem
February 23, 2011
22:06:15   February 23, 2011
22:06:15   February 23, 2011
22:06:15   February 23, 2011
22:06:15
Beirut   Moscow   Baghdad   Dubai
February 23, 2011
22:06:15   February 23, 2011
23:06:15   February 23, 2011
23:06:15   February 24, 2011
0:06:15
Bangkok   Jakarta   Hong Kong   Beijing
February 24, 2011
3:06:15   February 24, 2011
3:06:15   February 24, 2011
4:06:15   February 24, 2011
4:06:15
Shanghai   Seoul   Tokyo   Melbourne
February 24, 2011
4:06:15   February 24, 2011
5:06:15   February 24, 2011
5:06:15   February 24, 2011
7:06:15 DST
Sydney   Brisbane   Vladivostok   Kamchatka
February 24, 2011
7:06:15 DST   February 24, 2011
6:06:15   February 24, 2011
6:06:15   February 24, 2011
8:06:15
Code
Put this in the head part of the document

<script language="JavaScript">
<!--
function worldClock(zone, region){
var dst = 0
var time = new Date()
var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
var gmtTime = new Date(gmtMS)
var day = gmtTime.getDate()
var month = gmtTime.getMonth()
var year = gmtTime.getYear()
if(year < 1000){
year += 1900
}
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August",
            "September", "October", "November", "December")
var monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
if (year%4 == 0){
monthDays = new Array("31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}
if(year%100 == 0 && year%400 != 0){
monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}

var hr = gmtTime.getHours() + zone
var min = gmtTime.getMinutes()
var sec = gmtTime.getSeconds()

if (hr >= 24){
hr = hr-24
day -= -1
}
if (hr < 0){
hr -= -24
day -= 1
}
if (hr < 10){
hr = " " + hr
}
if (min < 10){
min = "0" + min
}
if (sec < 10){
sec = "0" + sec
}
if (day <= 0){
if (month == 0){
   month = 11
   year -= 1
   }
   else{
   month = month -1
   }
day = monthDays[month]
}
if(day > monthDays[month]){
   day = 1
   if(month == 11){
   month = 0
   year -= -1
   }
   else{
   month -= -1
   }
}
if (region == "NAmerica"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(2)
   startDST.setDate(1)
   var dayDST = startDST.getDay()
   if (dayDST != 0){
      startDST.setDate(8-dayDST)
      }
      else{
      startDST.setDate(1)
      }
   endDST.setMonth(9)
   endDST.setHours(1)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Europe"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(2)
   startDST.setHours(1)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(9)
   endDST.setHours(0)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}

if (region == "SAmerica"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(9)
   startDST.setHours(0)
   startDST.setDate(1)
   var dayDST = startDST.getDay()
   if (dayDST != 0){
      startDST.setDate(22-dayDST)
      }
      else{
      startDST.setDate(15)
      }
   endDST.setMonth(1)
   endDST.setHours(11)
   endDST.setDate(1)
   dayDST = endDST.getDay()
   if (dayDST != 0){
      endDST.setDate(21-dayDST)
      }
      else{
      endDST.setDate(14)
      }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST || currentTime < endDST){
      dst = 1
      }
}
if (region == "Cairo"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(0)
   startDST.setDate(30)
   var dayDST = startDST.getDay()
   if (dayDST < 5){
      startDST.setDate(28-dayDST)
      }
      else {
      startDST.setDate(35-dayDST)
      }
   endDST.setMonth(8)
   endDST.setHours(11)
   endDST.setDate(30)
   dayDST = endDST.getDay()
   if (dayDST < 4){
      endDST.setDate(27-dayDST)
      }
      else{
      endDST.setDate(34-dayDST)
      }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Israel"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(2)
   startDST.setDate(1)
   endDST.setMonth(8)
   endDST.setHours(2)
   endDST.setDate(25)
   dayDST = endDST.getDay()
   if (dayDST != 0){
   endDST.setDate(32-dayDST)
   }
   else{
   endDST.setDate(1)
   endDST.setMonth(9)
   }
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Beirut"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(2)
   startDST.setHours(0)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(9)
   endDST.setHours(11)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(30-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Baghdad"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(3)
   startDST.setHours(3)
   startDST.setDate(1)
   endDST.setMonth(9)
   endDST.setHours(3)
   endDST.setDate(1)
   dayDST = endDST.getDay()
      var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST && currentTime < endDST){
      dst = 1
      }
}
if (region == "Australia"){
   var startDST = new Date()
   var endDST = new Date()
   startDST.setMonth(9)
   startDST.setHours(2)
   startDST.setDate(31)
   var dayDST = startDST.getDay()
   startDST.setDate(31-dayDST)
   endDST.setMonth(2)
   endDST.setHours(2)
   endDST.setDate(31)
   dayDST = endDST.getDay()
   endDST.setDate(31-dayDST)
   var currentTime = new Date()
   currentTime.setMonth(month)
   currentTime.setYear(year)
   currentTime.setDate(day)
   currentTime.setHours(hr)
   if(currentTime >= startDST || currentTime < endDST){
      dst = 1
      }
}

   
if (dst == 1){
   hr -= -1
   if (hr >= 24){
   hr = hr-24
   day -= -1
   }
   if (hr < 10){
   hr = " " + hr
   }
   if(day > monthDays[month]){
   day = 1
   if(month == 11){
   month = 0
   year -= -1
   }
   else{
   month -= -1
   }
   }
return monthArray[month] + " " + day + ", " + year + "<br>" + hr + ":" + min + ":" + sec + " DST"
}
else{
return monthArray[month] + " " + day + ", " + year + "<br>" + hr + ":" + min + ":" + sec
}
}

function worldClockZone(){
document.getElementById("GMT").innerHTML = worldClock(0, "Greenwich")
document.getElementById("Vancouver").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("SanFrancisco").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("Seattle").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("LosAngeles").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("Denver").innerHTML = worldClock(-7, "NAmerica")
document.getElementById("MexicoCity").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Houston").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Minneapolis").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("NewOrleans").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Chicago").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Montgomery").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("Indianapolis").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Atlanta").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Detroit").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Miami").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("WashingtonDC").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Philadelphia").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("NewYork").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Montreal").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("Boston").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("BuenosAires").innerHTML = worldClock(-3, "BuenosAires")
document.getElementById("SaoPaulo").innerHTML = worldClock(-3, "SAmerica")
document.getElementById("RioDeJaneiro").innerHTML = worldClock(-3, "SAmerica")
document.getElementById("Lisbon").innerHTML = worldClock(0, "Europe")
document.getElementById("Dublin").innerHTML = worldClock(0, "Europe")
document.getElementById("London").innerHTML = worldClock(0, "Europe")
document.getElementById("Madrid").innerHTML = worldClock(1, "Europe")
document.getElementById("Barcelona").innerHTML = worldClock(1, "Europe")
document.getElementById("Paris").innerHTML = worldClock(1, "Europe")
document.getElementById("Brussels").innerHTML = worldClock(1, "Europe")
document.getElementById("Amsterdam").innerHTML = worldClock(1, "Europe")
document.getElementById("Frankfurt").innerHTML = worldClock(1, "Europe")
document.getElementById("Rome").innerHTML = worldClock(1, "Europe")
document.getElementById("Berlin").innerHTML = worldClock(1, "Europe")
document.getElementById("Prague").innerHTML = worldClock(1, "Europe")
document.getElementById("Vienna").innerHTML = worldClock(1, "Europe")
document.getElementById("Stockholm").innerHTML = worldClock(1, "Europe")
document.getElementById("Athens").innerHTML = worldClock(2, "Europe")
document.getElementById("Helsinki").innerHTML = worldClock(2, "Europe")
document.getElementById("Minsk").innerHTML = worldClock(2, "Europe")
document.getElementById("Istanbul").innerHTML = worldClock(2, "Europe")
document.getElementById("Cairo").innerHTML = worldClock(2, "Cairo")
document.getElementById("Jerusalem").innerHTML = worldClock(2, "Israel")
document.getElementById("Beirut").innerHTML = worldClock(2, "Beirut")
document.getElementById("Moscow").innerHTML = worldClock(3, "Europe")
document.getElementById("Baghdad").innerHTML = worldClock(3, "Baghdad")
document.getElementById("Dubai").innerHTML = worldClock(4, "Dubai")
document.getElementById("Bangkok").innerHTML = worldClock(7, "Bangkok")
document.getElementById("Jakarta").innerHTML = worldClock(7, "Jakarta")
document.getElementById("HongKong").innerHTML = worldClock(8, "HongKong")
document.getElementById("Beijing").innerHTML = worldClock(8, "Beijing")
document.getElementById("Shanghai").innerHTML = worldClock(8, "Shanghai")
document.getElementById("Seoul").innerHTML = worldClock(9, "Seoul")
document.getElementById("Tokyo").innerHTML = worldClock(9, "Tokyo")
document.getElementById("Melbourne").innerHTML = worldClock(10, "Australia")
document.getElementById("Sydney").innerHTML = worldClock(10, "Australia")
document.getElementById("Brisbane").innerHTML = worldClock(10, "Brisbane")
document.getElementById("Vladivostok").innerHTML = worldClock(10, "Europe")
document.getElementById("Kamchatka").innerHTML = worldClock(12, "Europe")

setTimeout("worldClockZone()", 1000)
}
window.onload=worldClockZone;

//-->
</script>

<style type="text/css">
.hrow {
font-weight:bold;
color: #C1E97C;
}
.hrow td{
padding-top: 20px;
width: 140px;
}
</style>

Put this in the body part of the document

<table cellspacing="5px">
<tr class="hrow">
<td>GMT</td><td>Vancouver</td><td>San Francisco</td><td>Seattle</td>
</tr>
<tr>
<td><span id="GMT"></span></td><td><span id="Vancouver"></span></td><td><span id="SanFrancisco"></span></td><td><span id="Seattle"></span></td>
</tr>
<tr class="hrow">
<td>Los Angeles</td><td>Denver</td><td>Mexico City</td><td>Houston</td>
</tr>
<tr>
<td><span id="LosAngeles"></span></td><td><span id="Denver"></span></td><td><span id="MexicoCity"></span></td><td><span id="Houston"></span></td>
</tr>
<tr class="hrow">
<td>Minneapolis</td><td>New Orleans</td><td>Chicago</td><td>Montgomery</td>
</tr>
<tr>
<td><span id="Minneapolis"></span></td><td><span id="NewOrleans"></span></td><td><span id="Chicago"></span></td><td><span id="Montgomery"></span></td>
</tr>
<tr class="hrow">
<td>Indianapolis</td><td>Atlanta</td><td>Detroit</td><td>Miami</td>
</tr>
<tr>
<td><span id="Indianapolis"></span></td><td><span id="Atlanta"></span></td><td><span id="Detroit"></span></td><td><span id="Miami"></span></td>
</tr>
<tr class="hrow">
<td>Washington DC</td><td>Philadelphia</td><td>New York</td><td>Montreal</td>
</tr>
<tr>
<td><span id="WashingtonDC"></span></td><td><span id="Philadelphia"></span></td><td><span id="NewYork"></span></td><td><span id="Montreal"></span></td>
</tr>
<tr class="hrow">
<td>Boston</td><td>Buenos Aires</td><td>Sao Paulo</td><td>Rio De Janeiro</td>
</tr>
<tr>
<td><span id="Boston"></span></td><td><span id="BuenosAires"></span></td><td><span id="SaoPaulo"></span></td><td><span id="RioDeJaneiro"></span></td>
</tr>
<tr class="hrow">
<td>Lisbon</td><td>Dublin</td><td>London</td><td>Madrid</td>
</tr>
<tr>
<td><span id="Lisbon"></span></td><td><span id="Dublin"></span></td><td><span id="London"></span></td><td><span id="Madrid"></span></td>
</tr>
<tr class="hrow">
<td>Barcelona</td><td>Paris</td><td>Brussels</td><td>Amsterdam</td>
</tr>
<tr>
<td><span id="Barcelona"></span></td><td><span id="Paris"></span></td><td><span id="Brussels"></span></td><td><span id="Amsterdam"></span></td>
</tr>
<tr class="hrow">
<td>Frankfurt</td><td>Rome</td><td>Berlin</td><td>Prague</td>
</tr>
<tr>
<td><span id="Frankfurt"></span></td><td><span id="Rome"></span></td><td><span id="Berlin"></span></td><td><span id="Prague"></span></td>
</tr>
<tr class="hrow">
<td>Vienna</td><td>Stockholm</td><td>Athens</td><td>Helsinki</td>
</tr>
<tr>
<td><span id="Vienna"></span></td><td><span id="Stockholm"></span></td><td><span id="Athens"></span></td><td><span id="Helsinki"></span></td>
</tr>
<tr class="hrow">
<td>Minsk</td><td>Istanbul</td><td>Cairo</td><td>Jerusalem</td>
</tr>
<tr>
<td><span id="Minsk"></span></td><td><span id="Istanbul"></span></td><td><span id="Cairo"></span></td><td><span id="Jerusalem"></span></td>
</tr>
<tr class="hrow">
<td>Beirut</td><td>Moscow</td><td>Baghdad</td><td>Dubai</td>
</tr>
<tr>
<td><span id="Beirut"></span></td><td><span id="Moscow"></span></td><td><span id="Baghdad"></span></td><td><span id="Dubai"></span></td>
</tr>
<tr class="hrow">
<td>Bangkok</td><td>Jakarta</td><td>Hong Kong</td><td>Beijing</td>
</tr>
<tr>
<td><span id="Bangkok"></span></td><td><span id="Jakarta"></span></td><td><span id="HongKong"></span></td><td><span id="Beijing"></span></td>
</tr>
<tr class="hrow">
<td>Shanghai</td><td>Seoul</td><td>Tokyo</td><td>Melbourne</td>
</tr>
<tr>
<td><span id="Shanghai"></span></td><td><span id="Seoul"></span></td><td><span id="Tokyo"></span></td><td><span id="Melbourne"></span></td>
</tr>
<tr class="hrow">
<td>Sydney</td><td>Brisbane</td><td>Vladivostok</td><td>Kamchatka</td>
</tr>
<tr>
<td><span id="Sydney"></span></td><td><span id="Brisbane"></span></td><td><span id="Vladivostok"></span></td><td><span id="Kamchatka"></span></td>
</tr>
</table>

    * JavaScript
    * Java

Newest Code

    * Java: Sort Algorithms Library (May 24)
    * Java: Quick Sort (May 24)
    * Java: Merge Sort (May 24)
    * Java: Shell Sort (May 24)
    * Java: Insertion Sort (May 24)
    * Java: Selection Sort (May 24)
    * Java: Bubble Sort (May 24)
    * Java: Font Viewer (May 08)
    * Javascript: Time Left Until... (Mar 15)
    * Javascript: Countdown (Mar 12)

View all code
Newest Lessons

    * javascript: Pop-up Windows (Dec 11)
    * javascript: Cookies (Dec 11)
    * javascript: The Image Object (Dec 11)
    * javascript: The Object Hier... (Dec 11)
    * javascript: Loops, Noscript... (Dec 11)
    * javascript: Use of The Date... (Dec 11)
    * javascript: Arrays and The ... (Dec 11)
    * javascript: Objects and The... (Dec 11)
    * javascript: Forms, Dialog B... (Dec 11)
    * javascript: If Statement, B... (Dec 11)

View all lessons
Most Popular Code

    * Javascript: World Clock (23858)
    * Java: Towers Of Hanoi (19966)
    * Java: Roll Dice (10956)

Most Popular Lessons

    * javascript: The Image Object (12339)
    * javascript: Objects and The... (4939)
    * javascript: Use of The Date... (3976)

Home | Code | Learn
©️ 2007-2008 ProgLogic, all rights reserved. | ProgLogic.com is created by Stijn Strickx. | e-mail

No inicio coloco <html> e acabo com </html>

É necessário colocar mais alguma coisa no código?

Não conheço html, estou a usar uma "plataforma" já pré configurada para fazer praticamente tudo graficamente...

Coloquei o mapa do google em código html sem problemas...

PS:estou a fazer copy past de um codigo

Obrigada
Cumps

paula91
Começando a Participar
Começando a Participar


Voltar ao Topo Ir em baixo

Resolvido Re: JavaScript para HTML

Mensagem por Marcos Guedes em 23/2/2011, 20:47

Vamos do começo...
Qual sua dificuldade?
Executar um javascript na página?
Existem várias maneiras para isto...

Uma delas seria algo bem simples:
Código:
<html>
<head>
<script language="javascript" type="text/javascript">
function alertar(mensagem)
{
alert(mensagem);
}
</script>
</head>
<body>
<a href='javascript:alertar("Exemplo encontrado no\nProgramação Brasil");'>Clique aqui!</a>
</body>
</html>

_________________
Marcos Guedes - Programador e desenvolvedor Web.


Visite o nosso portal:
http://portal.programacaobrasil.com

Marcos Guedes
Webmaster
Webmaster


Voltar ao Topo Ir em baixo

Resolvido Re: JavaScript para HTML

Mensagem por paula91 em 24/2/2011, 06:18

Pois eu estava a por essa estrutura...

Não sei se conheces o lv engine....estou a trabalhar por ai e eu escrevia as tags lá e o que acontecia depois de gravar é que ele apagáva.... Editei o html no visual studio e ficou a funcionar =)

Obrigada pela ajuda de qualquer das maneiras

paula91
Começando a Participar
Começando a Participar


Voltar ao Topo Ir em baixo

Resolvido Re: JavaScript para HTML

Mensagem por Fonsecca em 30/1/2012, 12:06

bom, ele já o ajudou, então... up

Fonsecca
Participa Pouco
Participa Pouco


Voltar ao Topo Ir em baixo

Resolvido Re: JavaScript para HTML

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum