Avatar billede martin29 Nybegynder
09. september 2005 - 14:30 Der er 6 kommentarer og
1 løsning

Undgå at dobbeltklikke for at få vist tid.

Hejsa!

Jeg vil godt have koden lavet om så man ikke skal dobbeltklikke for at se tiden. Men at tiderne blot vises ved at jeg kommer ind på siden. Er der en der lige vil hjælpe med at løse dette problem?

Mvh
Martin

kode ------------------

<script language=javaScript>
<!-- Beginning of JavaScript -

var worldtime = new Array()

worldtime[0]="Azores,-1"

worldtime[1]="Baghdad,3"

worldtime[2]="Beijing,8"

worldtime[3]="Berlin,1"

worldtime[4]="Buenos Aires,-3"

worldtime[5]="Chicago,-6"

worldtime[6]="Denver,-7"

worldtime[7]="Hong Kong,8"

worldtime[8]="Honolulu,-10"

worldtime[9]="Johannesburg,2"

worldtime[10]="Kairo,2"

worldtime[11]="Lima,-5"

worldtime[12]="London,0"

worldtime[13]="Mexico City,-6"

worldtime[14]="Moscow,3"

worldtime[15]="New York,-5"

worldtime[16]="Paris,1"

worldtime[17]="Perth,8"

worldtime[18]="Rio de Janheiro,-2"

worldtime[19]="San Francisco,-8"

worldtime[20]="Sydney,11"

worldtime[21]="Tokyo,9"

var hours

var shifthours

var minutes

var seconds

var localhours

var pause=2000

var thisplace

var thisline=""

var showmenu=1

function showtime() {

for (i=0; i<=worldtime.length-1;i++) {

thisplace=worldtime[i].split(",")

thistime= new Date()

hours=thistime.getUTCHours()

hours=eval(hours)

shifthours=eval(thisplace[1])

localhours=eval(shifthours+hours)

if (localhours <0) {localhours=24+localhours}

if (localhours >=24) {localhours=localhours-24}



minutes=thistime.getUTCMinutes()

seconds=thistime.getUTCSeconds()



if (thisplace[0]=='Delhi') {

minutes=eval(minutes+30)

if (minutes>=60) {

minutes=eval(minutes-60)

localhours=eval(localhours+1)

}

}

if (eval(minutes) < 10) {minutes="0"+minutes}

if (eval(seconds) < 10) {seconds="0"+seconds}

if (eval(localhours) < 10) {localhours="0"+localhours}

thisline+=localhours+":"+minutes+":"+seconds+" "+thisplace[0]+"<br>"

}

if (document.all) {

timediv.innerHTML=thisline

thisline=""

var timer=setTimeout("showtime()",1000)

}

if (document.layers) {

document.timediv.document.write("<span id='nn' class='timestyle'>")

document.timediv.document.write(thisline)

document.timediv.document.write("</span>")

document.timediv.document.close()

thisline=""

}

}



function dblclick() {

if (document.all && showmenu==1) {

document.all.timediv.style.visibility="visible"

document.all.timediv.style.posLeft=x

document.all.timediv.style.posTop=y

showtime()

}

if (document.layers && showmenu==1) {

document.timediv.visibility="visible"

document.timediv.left=x-40

document.timediv.top=y-80

showtime()

}

if (document.all && showmenu!=1) {

document.all.timediv.style.visibility="hidden"

}

if (document.layers && showmenu!=1) {

document.timediv.visibility="hidden"

}

showmenu=showmenu*-1

}



if (document.layers) {

document.captureEvents(Event.ONDBLCLICK);

}

document.ondblclick=dblclick;

if (document.layers){

document.captureEvents(Event.MOUSEMOVE);

}

document.onmousemove = handlerMM;

function handlerMM(e){

x = (document.layers) ? e.pageX : event.clientX

y = (document.layers) ? e.pageY : event.clientY

}

// - End of JavaScript - -->

</script>

<STYLE>

.timestyle {

position:absolute;

left:50px;

top:100px;

font-family:Verdana;

font-size:8pt;

color:880000;

background-color:DDDDFF;

}

.explainstyle {

position:absolute;

left:10px;

top:160px;

font-family:Verdana;

font-size:8pt;

color:000000;

}

</STYLE>

</head>

<body bgcolor=#FFFFFF>

<DIV id=source class="explainstyle"><b>RUN THE SCRIPT:</b><br>DOBBEL KLIKK HVOR SOM HELST PÅ SKJERMEN OG DU FÅR OPP OVERSIKT OVER HVOR MYE KLOKKEN ER I 22 HOVEDSTEDER. DOBBELKLIKK IGJEN OG OVERSIKTEN BLIE BORTE .<br></a></DIV>

<div id="timediv" class="timestyle"></div>

</body>
</html>
Avatar billede busschou Praktikant
09. september 2005 - 14:42 #1
i princippet kunne der nok gøres en masse men mon ikke det kan klares med at kalde funktionen dblclick i bodyen
---
<body bgcolor=#FFFFFF onload="dblclick();">
Avatar billede martin29 Nybegynder
09. september 2005 - 14:46 #2
Hejsa!

Det virker desværre ikke. :-)
http://www.shopfloor.dk/tid.htm
Avatar billede martin29 Nybegynder
09. september 2005 - 14:48 #3
linie 154 er
document.all.timediv.style.posLeft=x
Avatar billede busschou Praktikant
09. september 2005 - 14:56 #4
ok så sådan her, så kommer den frem på skærmen,
Hvis du ønsker en bestemt position må du tilføje x og y koordinatet igen
.---
<script type="text/javaScript">
var worldtime = new Array()
worldtime[0]="Azores,-1"
worldtime[1]="Baghdad,3"
worldtime[2]="Beijing,8"
worldtime[3]="Berlin,1"
worldtime[4]="Buenos Aires,-3"
worldtime[5]="Chicago,-6"
worldtime[6]="Denver,-7"
worldtime[7]="Hong Kong,8"
worldtime[8]="Honolulu,-10"
worldtime[9]="Johannesburg,2"
worldtime[10]="Kairo,2"
worldtime[11]="Lima,-5"
worldtime[12]="London,0"
worldtime[13]="Mexico City,-6"
worldtime[14]="Moscow,3"
worldtime[15]="New York,-5"
worldtime[16]="Paris,1"
worldtime[17]="Perth,8"
worldtime[18]="Rio de Janheiro,-2"
worldtime[19]="San Francisco,-8"
worldtime[20]="Sydney,11"
worldtime[21]="Tokyo,9"
var hours
var shifthours
var minutes
var seconds
var localhours
var pause=2000
var thisplace
var thisline=""
var showmenu=1

function showtime() {
  for (i=0; i<=worldtime.length-1;i++) {
    thisplace=worldtime[i].split(",")
    thistime= new Date()
    hours=thistime.getUTCHours()
    hours=eval(hours)
    shifthours=eval(thisplace[1])
    localhours=eval(shifthours+hours)
    if (localhours <0) {localhours=24+localhours}
    if (localhours >=24) {localhours=localhours-24}
    minutes=thistime.getUTCMinutes()
    seconds=thistime.getUTCSeconds()
    if (thisplace[0]=='Delhi') {
      minutes=eval(minutes+30)
      if (minutes>=60) {
        minutes=eval(minutes-60)
        localhours=eval(localhours+1)
      }
    }
    if (eval(minutes) < 10) {minutes="0"+minutes}
    if (eval(seconds) < 10) {seconds="0"+seconds}
    if (eval(localhours) < 10) {localhours="0"+localhours}
    thisline+=localhours+":"+minutes+":"+seconds+" "+thisplace[0]+"<br>"
  }
  if (document.all) {
    timediv.innerHTML=thisline
    thisline=""
    var timer=setTimeout("showtime()",1000)
  }
  if (document.layers) {
    document.timediv.document.write("<span id='nn' class='timestyle'>")
    document.timediv.document.write(thisline)
    document.timediv.document.write("</span>")
    document.timediv.document.close()
    thisline=""
  }
}

function dblclick() {
  if (document.all && showmenu==1) {
    document.all.timediv.style.visibility="visible"
    showtime()
  }
  if (document.layers && showmenu==1) {
    document.timediv.visibility="visible"
    showtime()
  }
  if (document.all && showmenu!=1) {
    document.all.timediv.style.visibility="hidden"
  }
  if (document.layers && showmenu!=1) {
    document.timediv.visibility="hidden"
  }
  showmenu=showmenu*-1
}
</script>

<STYLE>

.timestyle {
position:absolute;
left:50px;
top:100px;
font-family:Verdana;
font-size:8pt;
color:880000;
background-color:DDDDFF;
}
.explainstyle {
position:absolute;
left:10px;
top:160px;
font-family:Verdana;
font-size:8pt;
color:000000;
}
</STYLE>
</head>
<body bgcolor=#FFFFFF onload="dblclick();">
<DIV id=source class="explainstyle"><b>RUN THE SCRIPT:</b><br>DOBBEL KLIKK HVOR SOM HELST PÅ SKJERMEN OG DU FÅR OPP OVERSIKT OVER HVOR MYE KLOKKEN ER I 22 HOVEDSTEDER. DOBBELKLIKK IGJEN OG OVERSIKTEN BLIE BORTE .<br></a></DIV>
<div id="timediv" class="timestyle"></div>
</body>
</html>
Avatar billede martin29 Nybegynder
09. september 2005 - 15:04 #5
Yesss.
Tak for det. ;-)

Skal bruge det til at følge tiderne ude i verden så jeg har styr på hvornår det er passende at kontakte, den anden side af jorden. :-)

Smid et svar.

---
Mvh
Martin
Avatar billede busschou Praktikant
09. september 2005 - 15:16 #6
oki doki det gør jeg, godt det virker som ønsket :o)
Avatar billede martin29 Nybegynder
09. september 2005 - 15:21 #7
Det er bare perfekt til det jeg skal bruge det til.
Tak for hjælpen
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester