Visualizzazione dei risultati da 1 a 3 su 3

Discussione: name o id?

  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    4

    name o id?

    Premesso che sono abbastanza digiuno in materia, vi espongo il mio problema.
    Ho questo script prelevato qui su html.it (è un orologio).
    Nel codice html della pagina le immagini che deve richiamare sono identificate dal tag "name" che però è deprecato dal doctype strict che io voglio usare per la mia pagina.
    Ho provato a sostituire "name" con "id" ma il risultato è che su ie e su chrome lo script non funziona più, mentre continua ad andare su ff ed opera.
    Ho provato anche a mettere il doppio tag (sia neme che id) ma chiaramente poi la pagina non passa la validazione strict.
    Qualcuno potrebbe gentilmente aiutarmi a trovare una soluzione?
    Grazie

    codice:
    <!--
    var thistime,hours,minutes,seconds, marginbottom, marginright
    var ie=document.all?1:0
    var ns6=document.getElementById&&!document.all?1:0
    var ns4=document.layers?1:0
    var whichcorner=1
    var imgwidth=9
    var imgheight=5
    var hpadding=3
    var vpadding=3
    var watchwidth=2*hpadding+imgwidth
    var watchheight=12*vpadding+8*imgheight
    imga=new Image()
    imga.src="img/1.gif"
    imgb=new Image()
    imgb.src="img/2.gif"
    imgc=new Image()
    imgc.src="img/3.gif"
    imgd=new Image()
    imgd.src="img/4.gif"
    imge=new Image()
    imge.src="img/5.gif"
    imgf=new Image()
    imgf.src="img/6.gif"
    imgg=new Image()
    imgg.src="img/7.gif"
    imgh=new Image()
    imgh.src="img/8.gif"
    imgi=new Image()
    imgi.src="img/9.gif"
    function initclock() {
    if (ns4 || ns6) {
    marginbottom=window.innerHeight
    marginright=window.innerWidth
    }
    if (ie) {
    marginbottom=document.body.clientHeight
    marginright=document.body.clientWidth
    }
    if (whichcorner==1) {
    if (ie) {
    document.all.cornerclock.style.posLeft=0
    document.all.cornerclock.style.posTop=0
    }
    if (ns6) {
    document.getElementById("cornerclock").style.left=0
    document.getElementById("cornerclock").style.top=0
    }
    if (ns4) {
    document.cornerclock.left=0
    document.cornerclock.top=0
    }
    }
    if (whichcorner==2) {
    var posright=marginright-watchwidth
    if (ie) {
    document.all.cornerclock.style.posLeft=posright
    document.all.cornerclock.style.posTop=0
    }
    if (ns6) {
    document.getElementById("cornerclock").style.left=posright
    document.getElementById("cornerclock").style.top=0
    }
    if (ns4) {
    document.cornerclock.left=posright
    document.cornerclock.top=0
    }
    }
    clockon()
    }
    function clockon() {
    thistime= new Date()
    hours=""+thistime.getHours()
    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}
    var h1=hours.substring(0,1)+".gif"
    var h2=hours.substring(1,2)+".gif"
    var m1=minutes.substring(0,1)+".gif"
    var m2=minutes.substring(1,2)+".gif"
    var s1=seconds.substring(0,1)+".gif"
    var s2=seconds.substring(1,2)+".gif"
    if (ie || ns6) {
    document.sec2.src="img/"+s2
    document.sec1.src="img/"+s1
    document.min2.src="img/"+m2
    document.min1.src="img/"+m1
    document.hou2.src="img/"+h2
    document.hou1.src="img/"+h1
    }
    if (ns4) {
    document.cornerclock.document.sec2.src="img/"+s2
    document.cornerclock.document.sec1.src="img/"+s1
    document.cornerclock.document.min2.src="img/"+m2
    document.cornerclock.document.min1.src="img/"+m1
    document.cornerclock.document.hou2.src="img/"+h2
    document.cornerclock.document.hou1.src="img/"+h1
    }
    var timer=setTimeout("clockon()",1000)
    }
    if (ie || ns4 || ns6) {
    window.onload=initclock
    }
    //-->

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    if (ie || ns6) {
    document.sec2.src="img/"+s2
    document.sec1.src="img/"+s1
    document.min2.src="img/"+m2
    document.min1.src="img/"+m1
    document.hou2.src="img/"+h2
    document.hou1.src="img/"+h1
    }

    diventa
    if (ie || ns6) {
    document.getElementById('sec2').src="img/"+s2
    document.getElementById('sec1').src="img/"+s1
    document.getElementById('min2').src="img/"+m2
    document.getElementById('min1').src="img/"+m1
    document.getElementById('hou2').src="img/"+h2
    document.getElementById('hou1').src="img/"+h1
    }

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    4
    Perfetto, grazie Xinod, immaginavo che servisse una modifica del genere allo script ma da solo non ce l'avrei fatta. Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.