Salve a tutti!!!
Avrei un problemino di stringhe.
Sto scrivendo del codice per la gestione di un contatore con statistiche. In teoria sarebbe quasi finito se non fosse per un piccolo dettaglio.
Come qualsiasi contatore che si rispetti ho inserito 2 linee di javascript che mi ricavano la risoluzione dello schermo del visitatore in questo modo:
code:
--------------------------------------------------------------------------------
w = "<script>document.write(screen.width);</script>"
h = "<script>document.write(screen.height);</script>"
sName = w & "x" & h
--------------------------------------------------------------------------------
Così in sName dovrebbe esserci la risoluzione (ad es. "1024x768"), ed è così se provo a stampare tale variabile attraverso il response.write .
A questo punto mi servirebbe ricavarmi un ID da utilizzare nelle indicizzazioni del db, e quindi scrivo:
code:
--------------------------------------------------------------------------------
if instr(1, sName, "640x480", 1) then resID = 2
if instr(1, sName, "800x600", 1) then resID = 3
if instr(1, sName, "1024x768", 1) then resID = 4
if instr(1, sName, "1152x864", 1) then resID = 5
if instr(1, sName, "1280x768", 1) then resID = 6
if instr(1, sName, "1280x960", 1) then resID = 7
if instr(1, sName, "1280x1024", 1) then resID = 8
if instr(1, sName, "1600x1200", 1) then resID = 9
--------------------------------------------------------------------------------
ed è quì che iniziano i dolori di pancia. In pratica non imposta nessun resID, nonostante ci sia il corrispondente nei vari if (premetto che ho provato anche con il select case). Provo a controllare il tipo delle variabili con la funzione typename() che mi dice che sono tutte stringhe quelle su cui sto lavorando.
La cosa più bella è che lo stesso sistema lo uso per determinare i colori del sistema (funzione javascript -> catena di if) e funziona tutto alla perfezione...
Non so più cosa fare. Mi date una mano? Conoscete altri modi per fare quello che vorrei io?
Grazie
JmDeF
Onde evitare confusione questa è la funzione completa:
code:
--------------------------------------------------------------------------------
function IDres
dim w, h, sName
w = "<script>document.write(screen.width);</script>"
h = "<script>document.write(screen.height);</script>"
sName = w & "x" & h
response.write "sName: " & sName & "<BR>"
dim resID
if instr(1, sName, "640x480", 1) then resID = 2
if instr(1, sName, "800x600", 1) then resID = 3
if instr(1, sName, "1024x768", 1) then resID = 4
if instr(1, sName, "1152x864", 1) then resID = 5
if instr(1, sName, "1280x768", 1) then resID = 6
if instr(1, sName, "1280x960", 1) then resID = 7
if instr(1, sName, "1280x1024", 1) then resID = 8
if instr(1, sName, "1600x1200", 1) then resID = 9
response.write "type sName: " & typename(sName) & "<BR>"
response.write "type w: " & typename(w) & "<BR>"
IDres = resID
end function
--------------------------------------------------------------------------------