Autor | Zpráva | ||
---|---|---|---|
deader Profil * |
#1 · Zasláno: 31. 1. 2009, 17:33:54
Vytvarim si fotogalerii a potrebuji zjistit pomocí javascriptu původní velikost obrázku, abych mohl vypočítat poměr stran pro náhled. Zde je pokus, ktery vsak funguje pouze v chromu:
var h; if(document.innerHeight){ h=document.innerHeight; } else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight; } else if(document.body){ h=document.body.clientHeight; } h=Math.round(h*0.8); var pomer=objImage.width*1.25)/objImage.height; // zde je problem var w=(Math.round(h*pomer)); Dekuji za radu. |
||
AM_ Profil |
#2 · Zasláno: 1. 2. 2009, 19:09:51
Zkus ten obrázek zobrazit v neviditelném elementu (<img style="visibilty:hidden" id="test" ...) a pak document.getElementById('test').height. Nezkoušel jsem to a asi to není ideální řešení, ale mohlo by to fungovat.
|
||
habendorf Profil |
#3 · Zasláno: 1. 2. 2009, 19:22:51
img = new Image();
img.src = "http://diskuse.jakpsatweb.cz/img/logo.gif"; alert (img.height); |
||
deader Profil * |
#4 · Zasláno: 2. 2. 2009, 09:04:22
pise me to 0
|
||
deader Profil * |
#5 · Zasláno: 2. 2. 2009, 09:05:34
no jo to budu muset rozlisit prohlizece
|
||
deader Profil * |
#6 · Zasláno: 2. 2. 2009, 09:07:29
v ie to totiz jde
|
||
deader Profil * |
#7 · Zasláno: 2. 2. 2009, 09:10:41
ale jak to mam udelat v ostatnich?
|
||
deader Profil * |
#8 · Zasláno: 2. 2. 2009, 09:14:53
nejde to v khtml prohlizecich
|
||
deader Profil * |
#9 · Zasláno: 2. 2. 2009, 09:18:26
Uz to mam! V khtml funguje ta moznost od AM_, ale obrazek mam stejne zobrazen, takze je to vpoho, dik.
|
||
deader Profil * |
#10 · Zasláno: 2. 2. 2009, 09:42:19
Omlouvam se tak nefunguje, otevrel jsem jiny soubor. V KHTML to nejde.
|
||
deader Profil * |
#11 · Zasláno: 2. 2. 2009, 09:54:23
takže takhle to funguje:
imgNew = new Image(); imgNew.src = objLink.href; var h; if(document.innerHeight){ h=document.innerHeight; } else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight; } else if(document.body){ h=document.body.clientHeight; } h=Math.round(h*0.8); if(objImage.width) var pomer=(objImage.width*1.2)/objImage.height; else var pomer=(imgNew.width*1.2)/imgNew.height; alert(objImage.width);alert(imgNew.width); var w=Math.round(h*pomer); |
||
Chamurappi Profil |
#12 · Zasláno: 2. 2. 2009, 10:33:13
Reaguji na deadera:
Přestaň sem prosím chrlit jednořádkové příspěvky, tady není chat. Já bych to napsal takhle: var img = new Image(); img.onload = function() { alert(this.height); }; img.src = "http://diskuse.jakpsatweb.cz/img/logo.gif"; |
||
deader Profil * |
#13 · Zasláno: 2. 2. 2009, 11:05:54
to teďka řeším, díky za radu a promiň za ty příspěvky
|
||
Bubák Profil |
#14 · Zasláno: 2. 2. 2009, 11:15:23
A co událost obrázku onload?
|
||
Časová prodleva: 15 let
|
0