2013-04-25 16 views
6

HTML 5'in oturum belleğini sınamak için aşağıdaki kodu kullanıyorum. IE dışındaki tüm tarayıcılarda gayet iyi çalışıyor.oturum belleği IE'de çalışmıyor

<!DOCTYPE html> 
<html> 
<head> 
<script> 
function clickCounter() 
{ 
if(typeof(Storage)!=="undefined") 
    { 
    if (sessionStorage.clickcount) 
    { 
    sessionStorage.clickcount=Number(sessionStorage.clickcount)+1; 
    } 
    else 
    { 
    sessionStorage.clickcount=1; 
    } 
    document.getElementById("result").innerHTML="You have clicked the button " + sessionStorage.clickcount + " time(s) in this session."; 
    } 
else 
    { 
    document.getElementById("result").innerHTML="Sorry, your browser does not support web storage..."; 
    } 
} 
</script> 
</head> 
<body> 
<p><button onclick="clickCounter()" type="button">Click me!</button></p> 
<div id="result"></div> 
<p>Click the button to see the counter increase.</p> 
<p>Close the browser tab (or window), and try again, and the counter is reset.</p> 
</body> 
</html> 

Ne sorun olabilir: yüklü IE sürümü 10.

Kod nedir?

+0

her zaman artan bir sayaçtır. kullanıcı "beni tıkla" düğmesini tıklarsa –

+0

Sadece IE'de if (sessionStorage.clickcount) koşulunda tanımlanmamış başvurulardan dolayı betik hatasını gösterir. – Arun

+0

gibi, evet, oturum belleğinde ayarladıktan sonra bile çalışmaz. –

cevap

17

HTML5'in hem yerel depolama hem de oturum depolama özellikleriyle bulduğum şey, bu özelliklerin, sayfa HTTP aracılığıyla SADECE Internet Explorer'da çalışacak olması ve bu özelliklere erişmeye çalıştığınızda çalışmayacak olmasıdır yerel dosya sistemi üzerinde,

vb Tomcat gibi herhangi application server üzerine uygulamayı dağıtın ve sonra erişmek .. Eğer türlü URL C:/Users/Mitaksh/Desktop, vs ile dosya sisteminin doğrudan örnek bir web sayfasını açmaya çalıştığınız yani. ve sonra hem yerel hem de oturum depolama alanını görebilirsiniz ..

+2

Bir uygulama, yerel depolama veya oturum depolama içeren koddan Phonegap kullanılarak oluşturulduysa ve bu uygulama IE kullanan bir cihazda çalıştırılırsa, Sonuç ne olacak? – user2662157