1

私は IE10 を使用しており、2 つのタブがあります: - Tab1: index.html - Tab2: update.html

タブ 2 で:

        var tel = getURLParameter('TELNR');
        if (typeof (Storage) !== "undefined") { 
                     localStorage.setItem("telephone", "" + tel + ""); 
    }

タブ1:

                function handleStorage(oEvent) {
                   var telephone = localStorage.getItem("telephone");   
                   if (telephone != null) {
                      alert("New call from this phone number:" + telephone);
                   }
                };
            $(window).bind('storage', handleStorage);

まず、イベントの発生を待機する tab1 を開きます。次に、特定の電話番号を渡して tab2 を開きます。tab1 のリスナーは正しくトリガーされますが、電話は null です。tab2 を更新すると、今度は handleStorage が正しい番号で呼び出されます。

これは、Chrome と Firefox で完全に機能します。どんな手掛かり?

4

1 に答える 1

0

あなたのシナリオはよくわかりませんが、IE は、ページの読み込み時に他のブラウザーよりも localStorage にデータを入力するのが遅い/遅いことに注意してください。私はソフトページのリロードを行うことでこれに対処しました.IEのlocation.reload()の後、後続のページのロード中にlocalStorageデータが利用可能になります。

于 2014-01-14T12:07:26.933 に答える