2016-11-19 31 views
0

私はweb関連のアプリケーションに取り組んでいます。私はsessionStorageアイテムを表示しようとすると "undefined"を返します。sessionStorageはIE11で未定義と表示されますか?

IEの設定も変更されましたが、まだ同じになっています。

login.htmlページ:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
    <script type="text/javascript"> 
     var currentDate = new Date, 
     dformat = [(currentDate.getMonth() + 1), 
        currentDate.getDate(), 
        currentDate.getFullYear()].join('/') + 
        ' ' + 
       [currentDate.getHours(), 
        currentDate.getMinutes(), 
        currentDate.getSeconds()].join(':'); 

     function unicsession(length) { 
      var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"; 
      var sess = ""; 
      for (var x = 0; x < length; x++) { 
       var i = Math.floor(Math.random() * chars.length); 
       sess += chars.charAt(i); 
      } 
      return sess; 
     } 

     function generate() { 
      var intime = dformat; 
      sessionStorage.setItem("logintime", intime); 
      var username = document.getElementById("Username").value; 
      sessionStorage.setItem("username", username); 
      var unisession = unicsession(5); 
      sessionStorage.setItem("unisession", unisession); 
     } 
    </script> 
</head> 
<body> 
    <table> 
     <tr> 
      <td> 
       <input id="Username" type="text" /> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <a href="home.htm" onclick="generate()">Click here</a> 
      </td> 
     </tr> 
    </table> 
</body> 
</html> 

home.htmページのコード:私は、ログインページをクリックすると

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
    <script type="text/javascript"> 
     var getid = sessionStorage.getItem("username"); 
     var logintimes = sessionStorage.getItem("logintime"); 
     var unicsessionid = sessionStorage.getItem("unisession"); 
     var currentDate = new Date, 
     outformat = [(currentDate.getMonth() + 1), 
        currentDate.getDate(), 
        currentDate.getFullYear()].join('/') + 
        ' ' + 
       [currentDate.getHours(), 
        currentDate.getMinutes(), 
        currentDate.getSeconds()].join(':'); 
     function Getout() { 
      alert("Login Id: " + getid + " ; login Time: " + logintimes+" ; Unic Session-Id : "+unicsessionid+" ; Logout Time : "+outformat); 
     } 
</script> 
</head> 
<body> 
    <input id="logout" type="button" value="Logout" onclick="Getout()"/> 
</body> 
</html> 

は、それがホーム・ページにリダイレクトし、ホームページでのログアウトボタンをクリックした後、それ未定義と表示されます。

どうすればこの問題を解決できますか?

ご協力いただきありがとうございます。

答えて

0

sessionStorageは、ローカルファイルシステム経由でファイルにアクセスするとIEから入手できません。任意のローカルサーバーを使用してスクリプトをhttp://

関連する問題