Tôi đang sử dụng mã sau để kiểm tra dung lượng lưu trữ phiên của HTML 5 .. Nó hoạt động tốt trong tất cả trình duyệt ngoại trừ IE. Các phiên bản IE được cài đặt là 10.lưu trữ phiên không hoạt động trong IE
Code:
<!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>
gì có thể là vấn đề?
đó là bộ đếm được tăng lên mỗi lần e người dùng nhấp vào nút "nhấp vào tôi" –
Nó hiển thị lỗi tập lệnh do tham chiếu không xác định trong điều kiện if (sessionStorage.clickcount) chỉ trong IE giống như bạn đã nói – Arun
vâng ngay cả sau khi đặt nó trong bộ nhớ phiên nó không hoạt động. –