Jump to content
GSForum - Segélyvonal

JavaScriptes órák


Kiskalóz

Recommended Posts

Kiskalóz

Azt szeretném megoldani, hogy 1 oldalon több város órája jelenjen meg.

Egy sima óra scriptet találtam, és ezt át is tudtam irni, de azt nem tudtam megoldani, hogy ezek egyszerre is mûködjenek.

 

Pl van 1 budapest.js és egy tokio.js fájlom.

Amiket meghívok a így:

<head><script src="js/budapest.js"></SCRIPT>
<script src="js/tokio.js"></SCRIPT></head>

 

A js fájloknak ez a tartalma:


var clockid=new Array()
var clockidoutside=new Array()
var i_clock=-1
var thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
var thistime = hours+":"+minutes+":"+seconds
    
function writeclock() {
    i_clock++
    if (document.all || document.getElementById || document.layers) {
        clockid[i_clock]="clock"+i_clock
        document.write("<span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span>")
    }
}

function clockon() {
    thistime= new Date()
    hours=thistime.getHours()  //Ezt kell változtatni az idõ módosításhoz!!
    minutes=thistime.getMinutes()
    seconds=thistime.getSeconds()
    if (eval(hours) <10) {hours="0"+hours}
    if (eval(minutes) < 10) {minutes="0"+minutes}
    if (seconds < 10) {seconds="0"+seconds}
    thistime = hours+":"+minutes+":"+seconds
        
    if (document.all) {
        for (i=0;i<=clockid.length-1;i++) {
            var thisclock=eval(clockid[i])
            thisclock.innerHTML=thistime
        }
    }
    
    if (document.getElementById) {
        for (i=0;i<=clockid.length-1;i++) {
            document.getElementById(clockid[i]).innerHTML=thistime
        }
    }
    var timer=setTimeout("clockon()",1000)
}
window.onload=clockon

 

Ezzel pedig kiiratom:

<script>writeclock()</SCRIPT>

Viszont itt elakadtam!

Link to comment
Share on other sites

Arkangyal1528464506

Kezdésként rakosgasd be általánosan a szimpla szöveges meg zárójeles tagok után a ;-jelet. Nem vágom, hogy pontosan mit akarsz (clok mire jó, mit akarsz vele?), ha normalizálod ezt az egészet, akkor eléred, hogy ki legyen írva egy alkalommal az idõ egy span-ba (gondolom kéne egy "amíg valami" feltétel, mielõtt ezt csinálod).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...